From 96ee6b03ca9c3afaf0affcfdcaff1718a41baf8e Mon Sep 17 00:00:00 2001 From: JF Date: Sat, 28 Nov 2026 14:29:14 -0500 Subject: [PATCH 1/8] fix(python): a logpoint's message is checked on the session's own interpreter, and only a part that cannot run is rewritten debugpy evaluates the text between a logpoint's braces as a plain Python expression at every hit, so a message written like an f-string ({x!r}, {total:.2f}, {x=}) was accepted and then logged a syntax error at every hit, and a literal % in the text broke the line. The session now asks its own interpreter, with debugpy's own conversion and CPython's own compiler, when a run starts and when a logpoint is set on a live run. A message that runs as written is sent unchanged. A group that cannot compile alone is sent as an f-string literal inside the group, which the program's Python evaluates itself; a literal % is doubled only when the template cannot format for any values. Nothing is refused. An attach, a program on another interpreter, and any failure of the checker itself are "not checked", and the message goes out as written. `list_breakpoints` keeps the message the caller wrote; `logMessageSent` shows what was sent when it differs. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs --- .github/workflows/python-logpoint-corpus.yml | 83 + changelog.d/1334.fixed.md | 1 + docs/python/README.md | 13 + packages/shared/src/index.ts | 12 +- .../src/interfaces/adapter-policy-js.ts | 10 +- .../src/interfaces/adapter-policy-python.ts | 11 +- .../shared/src/interfaces/adapter-policy.ts | 80 +- .../src/interfaces/python-logpoint-check.ts | 578 ++ packages/shared/src/models/index.ts | 13 +- .../shared/src/utils/to-source-breakpoint.ts | 37 +- skills/debugging/references/python.md | 2 +- src/implementations/process-launcher-impl.ts | 12 +- src/proxy/adapter-cwd.ts | 21 + src/proxy/dap-proxy-worker.ts | 11 +- src/server.ts | 15 +- src/server/handlers/breakpoint-tools.ts | 13 +- src/server/tool-schemas.ts | 2 +- src/session/attach/attach-controller.ts | 5 +- .../breakpoints/breakpoint-controller.ts | 15 + src/session/breakpoints/logpoint-checks.ts | 134 + src/session/launch/debug-launcher.ts | 3 + src/session/launch/proxy-launcher.ts | 85 +- src/session/launch/spawn-command.ts | 47 +- src/session/log-message-checkers.ts | 546 ++ src/session/operations-context.ts | 17 +- src/session/session-manager-core.ts | 82 +- src/session/session-manager-operations.ts | 4 +- src/session/session-store.ts | 5 + .../integration/logpoint-corpus/corpus.json | 3759 ++++++++ .../integration/logpoint-corpus/emulate.py | 333 + .../integration/logpoint-corpus/fuzz.py | 135 + .../integration/logpoint-corpus/table.json | 8248 +++++++++++++++++ .../integration/logpoint-interpreters.ts | 49 + .../python-logpoint-corpus.test.ts | 196 + .../integration/python-logpoint-live.test.ts | 204 + .../integration/python-logpoint-paths.test.ts | 355 + .../bp-assert.va-explicit.container-true.json | 2 +- ...bp-assert.va-explicit.container-unset.json | 2 +- .../bp-assert.va-open.container-true.json | 2 +- .../bp-assert.va-open.container-unset.json | 2 +- .../bp-assert.va-unset.container-true.json | 2 +- .../bp-assert.va-unset.container-unset.json | 2 +- ...bp-content.va-explicit.container-true.json | 2 +- ...p-content.va-explicit.container-unset.json | 2 +- .../bp-content.va-open.container-true.json | 2 +- .../bp-content.va-open.container-unset.json | 2 +- .../bp-content.va-unset.container-true.json | 2 +- .../bp-content.va-unset.container-unset.json | 2 +- .../bp-line.va-explicit.container-true.json | 2 +- .../bp-line.va-explicit.container-unset.json | 2 +- .../bp-line.va-open.container-true.json | 2 +- .../bp-line.va-open.container-unset.json | 2 +- .../bp-line.va-unset.container-true.json | 2 +- .../bp-line.va-unset.container-unset.json | 2 +- .../bp-unset.va-explicit.container-true.json | 2 +- .../bp-unset.va-explicit.container-unset.json | 2 +- .../bp-unset.va-open.container-true.json | 2 +- .../bp-unset.va-open.container-unset.json | 2 +- .../bp-unset.va-unset.container-true.json | 2 +- .../bp-unset.va-unset.container-unset.json | 2 +- .../server/server-logpoint-gating.test.ts | 27 +- .../breakpoint-controller-armed-pause.test.ts | 3 +- .../breakpoint-controller-live-sync.test.ts | 3 +- ...eakpoint-controller-logpoint-check.test.ts | 111 + ...eakpoint-controller-pending-answer.test.ts | 3 +- .../breakpoints/breakpoint-controller.test.ts | 3 +- .../breakpoints/logpoint-checks.test.ts | 97 + .../unit/session/debug-result-data.test.ts | 1 + .../session/launch/proxy-launcher.test.ts | 165 +- .../unit/session/log-message-checkers.test.ts | 363 + ...ssion-manager-child-logpoint-check.test.ts | 119 + .../unit/logpoint-message-model-guard.test.ts | 69 + .../shared/adapter-policy-contract.test.ts | 17 + tests/unit/shared/adapter-policy-js.test.ts | 18 +- .../unit/shared/python-logpoint-check.test.ts | 193 + 75 files changed, 16274 insertions(+), 102 deletions(-) create mode 100644 .github/workflows/python-logpoint-corpus.yml create mode 100644 changelog.d/1334.fixed.md create mode 100644 packages/shared/src/interfaces/python-logpoint-check.ts create mode 100644 src/proxy/adapter-cwd.ts create mode 100644 src/session/breakpoints/logpoint-checks.ts create mode 100644 src/session/log-message-checkers.ts create mode 100644 tests/adapters/python/integration/logpoint-corpus/corpus.json create mode 100644 tests/adapters/python/integration/logpoint-corpus/emulate.py create mode 100644 tests/adapters/python/integration/logpoint-corpus/fuzz.py create mode 100644 tests/adapters/python/integration/logpoint-corpus/table.json create mode 100644 tests/adapters/python/integration/logpoint-interpreters.ts create mode 100644 tests/adapters/python/integration/python-logpoint-corpus.test.ts create mode 100644 tests/adapters/python/integration/python-logpoint-live.test.ts create mode 100644 tests/adapters/python/integration/python-logpoint-paths.test.ts create mode 100644 tests/core/unit/session/breakpoints/breakpoint-controller-logpoint-check.test.ts create mode 100644 tests/core/unit/session/breakpoints/logpoint-checks.test.ts create mode 100644 tests/core/unit/session/log-message-checkers.test.ts create mode 100644 tests/core/unit/session/session-manager-child-logpoint-check.test.ts create mode 100644 tests/unit/logpoint-message-model-guard.test.ts create mode 100644 tests/unit/shared/python-logpoint-check.test.ts diff --git a/.github/workflows/python-logpoint-corpus.yml b/.github/workflows/python-logpoint-corpus.yml new file mode 100644 index 000000000..5c1d60b5a --- /dev/null +++ b/.github/workflows/python-logpoint-corpus.yml @@ -0,0 +1,83 @@ +name: Python logpoint corpus + +# The Python logpoint check (issues #1334, #1349) on the second side of the +# f-string grammar change in Python 3.12. ci.yml's build-and-test job runs the +# same corpus on its own Python (3.11); this job runs it on 3.13, row by row, +# against what was recorded for that interpreter. Pull requests that touch +# the check, and on demand; never on a push to main (ci.yml is the badge). + +on: + pull_request: + branches: [ main ] + paths: + - 'packages/shared/src/interfaces/python-logpoint-check.ts' + - 'packages/shared/src/interfaces/adapter-policy-python.ts' + - 'packages/shared/src/interfaces/adapter-policy.ts' + - 'packages/shared/src/utils/to-source-breakpoint.ts' + - 'packages/adapter-python/src/**' + - 'src/session/log-message-checkers.ts' + - 'src/session/breakpoints/logpoint-checks.ts' + - 'src/session/breakpoints/breakpoint-controller.ts' + - 'src/session/launch/proxy-launcher.ts' + - 'src/session/launch/spawn-command.ts' + - 'src/session/session-manager-core.ts' + - 'src/proxy/adapter-cwd.ts' + - 'tests/adapters/python/integration/logpoint-interpreters.ts' + - 'tests/adapters/python/integration/python-logpoint-*.test.ts' + - 'tests/adapters/python/integration/logpoint-corpus/**' + - 'requirements/debugpy.txt' + - '.github/workflows/python-logpoint-corpus.yml' + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: python-logpoint-corpus-${{ github.ref }} + cancel-in-progress: true + +jobs: + corpus: + name: Logpoint corpus (Python ${{ matrix.python-version }}) + runs-on: ubuntu-latest + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + # 3.12 has no recorded expectations yet: the corpus test fails on an + # interpreter it has none for rather than passing on invariants alone. + python-version: ['3.13'] + steps: + - name: Checkout code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: Setup pnpm + uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 + - name: Setup Node.js + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: '22.x' + cache: 'pnpm' + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 + with: + python-version: ${{ matrix.python-version }} + - name: Install Python dependencies + run: | + python -m pip install --require-hashes -r requirements/pip.txt + python -m pip install --require-hashes -r requirements/debugpy.txt + python -c "import sys, debugpy; print(sys.version, debugpy.__version__)" + - name: Install dependencies + run: pnpm install --frozen-lockfile + env: + SKIP_ADAPTER_VENDOR: 'true' + - name: Build project + run: pnpm run build:ci + # Both suites skip without a Python that has debugpy; a skip here would + # mean this job proved nothing, so the report must show passes and no skips. + - name: Run the logpoint corpus, emulated and live + env: + MCP_LOGPOINT_PYTHONS: python + PYTHON_PATH: python + run: | + pnpm exec vitest run --project integration tests/adapters/python/integration/python-logpoint-corpus.test.ts tests/adapters/python/integration/python-logpoint-live.test.ts --reporter=default --reporter=json --outputFile=/tmp/logpoint-corpus.json + node -e "const r=require('/tmp/logpoint-corpus.json'); console.log('passed', r.numPassedTests, 'skipped', r.numPendingTests + r.numTodoTests); if (r.numPassedTests === 0 || r.numPendingTests + r.numTodoTests > 0) process.exit(1)" diff --git a/changelog.d/1334.fixed.md b/changelog.d/1334.fixed.md new file mode 100644 index 000000000..ae8dfa4d3 --- /dev/null +++ b/changelog.d/1334.fixed.md @@ -0,0 +1 @@ +**A Python logpoint written like an f-string, or with a literal `%` in its text, logs what it means instead of an error at every hit** — debugpy evaluates each `{...}` group of a `logMessage` as a plain Python expression inside one `%`-template, so `{entry!r}`, `{total:.2f}` and `{x=}` were accepted and then logged `invalid syntax (, line 1)` (or `invalid decimal literal`) at every hit, and `100% {x}` logged `unsupported format character`. Now, when a launch starts (and for a logpoint set while the program runs), the program's own interpreter checks each message with the debugpy it runs: a message that runs is sent exactly as written; one that cannot run for any values gets the smallest repair that interpreter validates — each failing group as the same field written as an f-string (`{f'{entry!r}'}`), the text's `%` doubled where the template cannot format — and the answer shows `logMessageSent` (what debugpy received) and `logMessageCheck` (why, and on which Python and debugpy); one with no such repair is sent as written and the answer says what every hit will log; an assignment expression (`{step:=99}`) is named, because where it runs it assigns. Nothing is refused, `list_breakpoints` keeps the message as written in `logMessage`, and the launch, restart and attach answers list the logpoints the check had something to say about in `logMessageChecks`. Not checked, and sent as written with the reason: an attach, a launch that names its own `python`, `pythonPath` or `pythonArgs`, and a child process whose interpreter cannot be confirmed as the checked one (#1334, #1349) diff --git a/docs/python/README.md b/docs/python/README.md index 1dfcc830c..0027c19f8 100644 --- a/docs/python/README.md +++ b/docs/python/README.md @@ -65,6 +65,19 @@ set_breakpoint { "sessionId": "...", "file": "/abs/path/script.py", "line": 15, A logpoint never pauses: it interpolates the `{expressions}` and writes the line to `get_output` while the program keeps running. Each hit does cost time, however — measured at 24.7 µs per hit on Python 3.13 + debugpy (`sys.monitoring`, 2.5% of a core at 1,000 hits/s), and placing a logpoint anywhere in a function slows that whole function by 58× — so keep logpoints off tight loops. When hits outrun debugpy's delivery rate (measured at 3,200–4,400 lines/s during a run and about 6,000 lines/s draining afterward), lines still queued when the program exits are lost and the session's end answer does not report the loss (issue #1265). See [Logpoints](../tool-reference.md#logpoints) for measurement conditions and what was not measured. +#### What a logpoint message may contain + +A field is an expression in the program's language. For Python, f-string field syntax (`{x!r}`, `{total:.2f}`, `{x=}`) is accepted where the server checked the message on the program's own interpreter, which is a launched session. Elsewhere the message goes to debugpy as written, which evaluates each field as a plain expression, and the answer says it was not checked. debugpy's own reading wins whenever it can run the message: `{{x}}` is a set and `%%` is `%`. + +debugpy turns the message into one Python expression — the text becomes a `%`-template and each `{...}` group a plain expression — and evaluates it at every hit. When the launch starts (and for a logpoint set while the program runs), the server asks the program's own interpreter, with the debugpy it runs, whether that expression can run; nothing is evaluated in that check, and nothing is refused: + +- A message that runs is sent exactly as written. If it contains an assignment expression (`{step:=99}`, which an f-string would read as a format spec), the answer says so, because where it runs it assigns — on Python 3.13 and later to the running function's own variable — and names the f-string reading. +- A message that cannot run for any values is repaired in the smallest way that the interpreter validates: each group that does not compile on its own becomes the same field as an f-string (`{x!r}` is sent as `{f'{x!r}'}`), and when the text cannot be formatted with `%` for any values (`100% {x}`), the text's `%` is doubled. Every other part is untouched. The answer shows `logMessageSent`, what debugpy received, and `logMessageCheck`, why; `list_breakpoints` keeps the message you wrote in `logMessage`. +- A message that cannot run and has no such repair (a brace inside a string in a field, `{d['}']}`, which debugpy splits there) is sent as written, and the answer says what every hit will log. +- Not checked, and sent as written, with the reason in the answer: an attach (the program runs in a process this server did not start), a launch that names its own interpreter or interpreter flags (`python`, `pythonPath`, `pythonArgs`), a child process whose interpreter cannot be confirmed as the checked one, a message longer than 4,096 characters, a `%`-directive width or precision of more than 4 digits or widths adding up to more than 65,536, and anything the check itself could not finish (its recursion limit, for one). + +The check runs in a short-lived helper process on the program's interpreter, started for a run's first logpoint and stopped when the run ends, on `close_debug_session`, and when the server exits; it reads its input until the server goes away. A repair claims only a compile: it was not run, and real values can still raise. A rewritten field is different source text from the one you wrote, so a program that inspects what it compiles — an audit hook that judges `compile` events by their source — can tell `{f'{x!r}'}` from `{repr(x)}` and treat them differently. + ### 3. Start Debugging Start debugging your Python script: diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index b6e4396fc..f1fa369fd 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -196,6 +196,10 @@ export type { LiveUpdateRequest, ProgramEndContext, ProgramEndExplanation, + LogMessageVerdict, + LogMessageChecker, + LogMessageCheckerSpec, + LogMessageCheckerReply, ChildSessionStrategy, AdapterSpecificState, CommandHandling, @@ -236,6 +240,12 @@ export { } from './interfaces/js-launch-defaults.js'; export type { JsLaunchSkipInputs, JsLaunchSourceMapInputs, JsLaunchWorkspaceOptions } from './interfaces/js-launch-defaults.js'; export { PythonAdapterPolicy } from './interfaces/adapter-policy-python.js'; +export { + PYTHON_LOGPOINT_CHECKER, + PYTHON_LOGPOINT_CHECKER_SOURCE, + checkPythonLogMessage, + verdictFromCheckerAnswer +} from './interfaces/python-logpoint-check.js'; export { RubyAdapterPolicy } from './interfaces/adapter-policy-ruby.js'; export { RustAdapterPolicy } from './interfaces/adapter-policy-rust.js'; export { CppAdapterPolicy } from './interfaces/adapter-policy-cpp.js'; @@ -311,7 +321,7 @@ export { type VersionProbeOptions, type VersionProbeResult } from './utils/version-probe.js'; -export { toSourceBreakpoint, toWireSourceBreakpoint, type BreakpointFields, toFunctionBreakpoint, type FunctionBreakpointFields } from './utils/to-source-breakpoint.js'; +export { toSourceBreakpoint, toWireSourceBreakpoint, type BreakpointFields, toFunctionBreakpoint, type FunctionBreakpointFields, toInitialBreakpoint, type InitialBreakpoint } from './utils/to-source-breakpoint.js'; export { JS_LOGPOINT_BINDING, JS_LOGPOINT_CLEAR, diff --git a/packages/shared/src/interfaces/adapter-policy-js.ts b/packages/shared/src/interfaces/adapter-policy-js.ts index dae78dbf0..6cb457f69 100644 --- a/packages/shared/src/interfaces/adapter-policy-js.ts +++ b/packages/shared/src/interfaces/adapter-policy-js.ts @@ -6,7 +6,7 @@ */ import type { DebugProtocol } from '@vscode/debugprotocol'; import * as path from 'path'; -import type { AdapterPolicy, AdapterSpecificState, CommandHandling, LocalVariableExtraction, QueuedDapCommand, StopReasonContext, PendingStopContext, StepInFilterContext, UnresolvedSourceContext, GeneratedFileCandidate, GeneratedFileContext } from './adapter-policy.js'; +import type { AdapterPolicy, AdapterSpecificState, CommandHandling, LocalVariableExtraction, LogMessageVerdict, QueuedDapCommand, StopReasonContext, PendingStopContext, StepInFilterContext, UnresolvedSourceContext, GeneratedFileCandidate, GeneratedFileContext } from './adapter-policy.js'; import { generatedFileCandidatesFrom } from './adapter-policy.js'; import { jsLaunchBlackboxesNodeModules, @@ -324,8 +324,12 @@ export const JsDebugAdapterPolicy = { condition: compiled.condition }; }, - validateLogMessage: (logMessage: string, condition?: string): string | undefined => - validateJsLogpoint(logMessage, condition), + // A message that does not compile is refused up front (issue #853); the + // checker argument is never used: the compile is this policy's own. + validateLogMessage: (logMessage: string, condition?: string): LogMessageVerdict => { + const problem = validateJsLogpoint(logMessage, condition); + return problem === undefined ? { status: 'runs' } : { status: 'refused', reason: problem }; + }, // js-debug implements no DAP setFunctionBreakpoints (upstream out of scope, // vscode-js-debug#952), so ours are delivered out of band (issue #295): the // proxy's CdpFunctionBreakpointBridge resolves names over the child diff --git a/packages/shared/src/interfaces/adapter-policy-python.ts b/packages/shared/src/interfaces/adapter-policy-python.ts index d10e3c015..b2832c16e 100644 --- a/packages/shared/src/interfaces/adapter-policy-python.ts +++ b/packages/shared/src/interfaces/adapter-policy-python.ts @@ -4,8 +4,9 @@ * Encodes debugpy specific behaviors and variable handling logic. */ import type { DebugProtocol } from '@vscode/debugprotocol'; -import type { AdapterPolicy, AdapterSpecificState, CommandHandling, LocalVariableExtraction, StepInFilterContext, UnboundBreakpointContext } from './adapter-policy.js'; +import type { AdapterPolicy, AdapterSpecificState, CommandHandling, LocalVariableExtraction, LogMessageChecker, LogMessageVerdict, StepInFilterContext, UnboundBreakpointContext } from './adapter-policy.js'; import { emptyLocalVariableExtraction, extractionFromScope } from './adapter-policy.js'; +import { checkPythonLogMessage } from './python-logpoint-check.js'; import type { StackFrame, Variable } from '../models/index.js'; import type { DapClientBehavior, DapClientContext, ReverseRequestResult } from './dap-client-behavior.js'; import type { ChildAdoptionContract, ChildReport } from './child-adoption.js'; @@ -111,6 +112,14 @@ export const PythonAdapterPolicy = { // correctly, sends no `initialized`: the worker does not wait for one (#746). honoursNoDebug: true, supportsLogPoints: true, + // debugpy evaluates each `{...}` group of a logMessage as a plain Python + // expression at every hit, so an f-string-style field (`{x!r}`) or a + // literal `%` in the text can log an error at every hit (issues #1334, + // #1349). The program's own interpreter checks the message; nothing is + // refused, a message that runs goes as written, and before any run there + // is no verdict: the launch checks it. + validateLogMessage: (logMessage: string, _condition?: string, checker?: LogMessageChecker): Promise | undefined => + checker ? checkPythonLogMessage(logMessage, checker) : undefined, supportsFunctionBreakpoints: true, supportsReverseStartDebugging: false, // debugpy runs exactly one of these (`debugpy/adapter/clients.py`: '"program", diff --git a/packages/shared/src/interfaces/adapter-policy.ts b/packages/shared/src/interfaces/adapter-policy.ts index cb95339a7..9b21fe331 100644 --- a/packages/shared/src/interfaces/adapter-policy.ts +++ b/packages/shared/src/interfaces/adapter-policy.ts @@ -471,6 +471,62 @@ export interface ProgramEndExplanation { data?: Record; } +/** + * What a policy found about one logpoint message (issues #1334, #1349). The + * core stores it beside the breakpoint, sends `wire` in place of the message + * only for `rewritten`, and repeats `note` in the answers; the stored + * `logMessage` is always the caller's. `refused` is JavaScript's existing + * up-front refusal (issue #853) and no other policy's. + */ +export type LogMessageVerdict = + /** The message runs as written. `note` only when there is something to say (an assignment). */ + | { status: 'runs'; assigns?: string[]; note?: string } + /** It cannot run as written, and `wire` is the policy's checked repair of the failing parts. */ + | { status: 'rewritten'; wire: string; groups: string[]; percentDoubled: boolean; note: string; assigns?: string[] } + /** It cannot run as written, and no repair was found: sent as written. */ + | { status: 'fails'; note: string; group?: string } + /** Not checked, and why: sent as written. */ + | { status: 'unchecked'; note: string } + | { status: 'refused'; reason: string }; + +/** + * How a policy's checker process is started on the run's own runtime: the + * arguments that follow the executable of the run's adapter command. The + * core starts it lazily, once per run and key, with that command's + * environment and the adapter's working directory, and owns its lifecycle; + * what the arguments mean is the policy's. + */ +export interface LogMessageCheckerSpec { + /** Names the process within a run: one per key. */ + key: string; + /** The arguments to the run's runtime executable. */ + args: readonly string[]; +} + +/** One answer from a checker process, or why there is none (a bound, a crash, no runtime to ask). */ +export type LogMessageCheckerReply = + | { ok: true; value: unknown } + | { ok: false; cause: string }; + +/** + * What the core hands `validateLogMessage` when it can say where the message + * will run (issues #1334, #1349). Absent before any run: the policy then + * decides nothing, and the launch checks the message. + */ +export interface LogMessageChecker { + /** + * Ask the policy's checker on the run's runtime. Answers `ok: false` with + * the reason when there is no runtime of this server's to ask (an attach), + * when the run ended, or when the checker failed or hit a bound; never + * throws. The core bounds every call in time and size. + */ + ask(spec: LogMessageCheckerSpec, request: unknown): Promise; + /** The launch configuration the adapter receives, merged and transformed; absent for an attach. */ + readonly launchConfig?: Readonly>; + /** Set when the message is checked for an adopted child session: the adapter's report of it. */ + readonly child?: { readonly targetId: string; readonly configuration: Readonly> }; +} + export interface AdapterPolicy { /** * Identifying name for diagnostics (e.g., 'default', 'js-debug') @@ -504,13 +560,23 @@ export interface AdapterPolicy { toWireBreakpoint?(bp: BreakpointFields): DebugProtocol.SourceBreakpoint; /** - * Up-front check of a logMessage (and its optional condition) for a policy - * that compiles logpoints itself (issue #853): the returned text refuses - * set_breakpoint the way an expectedContent mismatch does, instead of the - * adapter reporting the syntax error only in its output stream. Undefined - * means the message is acceptable (or the policy does not pre-validate). - */ - validateLogMessage?(logMessage: string, condition?: string): string | undefined; + * The policy's check of a logMessage (and its optional condition). Called + * without a checker at set_breakpoint time, where only a synchronous + * `refused` counts: js-debug compiles logpoints itself and refuses one that + * does not compile, the way an expectedContent mismatch is refused, instead + * of the adapter reporting the error only in its output stream (issue #853). + * Called with a checker once the core knows where the message will run (a + * launch, a live set on a launched or attached run, an adopted child): + * debugpy evaluates each brace group as a plain expression, so the Python + * policy asks the program's own interpreter, sends a checked repair of a + * message that cannot run as written, and refuses nothing (issues #1334, + * #1349). Undefined means the policy has nothing to say here. + */ + validateLogMessage?( + logMessage: string, + condition?: string, + checker?: LogMessageChecker + ): LogMessageVerdict | undefined | Promise; /** * Static pre-launch knowledge of function-breakpoint support (issue #271 diff --git a/packages/shared/src/interfaces/python-logpoint-check.ts b/packages/shared/src/interfaces/python-logpoint-check.ts new file mode 100644 index 000000000..a36ee6690 --- /dev/null +++ b/packages/shared/src/interfaces/python-logpoint-check.ts @@ -0,0 +1,578 @@ +/** + * The Python policy's logpoint check (issues #1334, #1349). + * + * debugpy turns a logMessage into one Python expression with pydevd's + * `convert_dap_log_message_to_expression` — the text becomes a `%`-template + * and every `{...}` group a plain expression in its tuple — and evaluates it + * at every hit. A message written like an f-string (`{x!r}`, `{total:.2f}`, + * `{x=}`) is accepted and then logs a syntax error at every hit, and a literal + * `%` in the text can break the template. + * + * Nothing here reads the message. The checker below runs on the program's own + * interpreter, with the adapter's environment and working directory, so it + * imports the debugpy the program runs: debugpy's own conversion and brace + * matcher, CPython's own compile() and ast, and CPython's own `%` with every + * element 1 decide. A message that runs is sent as written, unchanged; one + * that cannot run for any values gets the smallest repair that validates (the + * failing groups as f-string fields, the text's `%` doubled); anything the + * checker could not establish is sent as written and said to be unchecked. + * Nothing is refused. + */ +import type { LogMessageChecker, LogMessageCheckerSpec, LogMessageVerdict } from './adapter-policy.js'; + +/** + * The checker, started as ` -X utf8 -c `. It must contain no + * backtick and no dollar-brace (it is a raw template literal). + */ +export const PYTHON_LOGPOINT_CHECKER_SOURCE = String.raw`"""mcp-debugger's logpoint checker for debugpy (issues #1334, #1349). + +Started by the server on the interpreter, environment and working directory of the run's +debug adapter, so "import debugpy" finds the debugpy the program will run, as +" -X utf8 -c ". One JSON object per line in each direction, ASCII only. +It exits when its input closes. + + {"op": "check", "m": } the verdict for one logpoint message + {"op": "sameInterpreter", "pid": } whether a local process runs on this interpreter + +Nothing here runs the message: it calls debugpy's own conversion, CPython's own compile() +and ast.parse(), and formats pydevd's constant %-template with every element equal to 1. + + runs debugpy's conversion compiles and its %-template formats with every element 1: + sent as written. "assigns" names what an assignment expression in it binds. + rewritten it cannot run for any values, and replacing only the groups that do not compile + on their own with the same field as an f-string (doubling the text's % when the + template still cannot format) gives a form debugpy's conversion compiles, whose + untouched parts are unchanged. + fails it cannot run for any values, and no such form was found: sent as written. + unchecked a bound declined it, or this process could not finish the check (recursion, + memory): sent as written. A limit of this process is never a verdict on the text. +""" +import ast +import json +import os +import re +import sys +import warnings + +MAX_MESSAGE = 4096 +# A %-directive's width or precision is formatted only up to 4 digits, and the widths and +# precisions of one template only up to this sum: the formatted line is bounded before any +# formatting happens (conservative: a literal "%%12345" is counted too). +MAX_DIGITS = 4 +MAX_WIDTH_SUM = 65536 + + +class Decline(Exception): + """The check cannot be finished here; the message is sent as written.""" + + +try: + import debugpy + + _pydevd = os.path.join(os.path.dirname(debugpy.__file__), "_vendored", "pydevd") + if _pydevd not in sys.path: + sys.path.insert(0, _pydevd) + from _pydevd_bundle import pydevd_utils + + conv = pydevd_utils.convert_dap_log_message_to_expression + nested = pydevd_utils._extract_variable_nested_braces + VERSIONS = {"python": sys.version.split()[0], "debugpy": str(debugpy.__version__)} + IMPORT_ERROR = None +except Exception as e: # noqa: BLE001 every check answers "unchecked" + conv = nested = None + VERSIONS = {"python": sys.version.split()[0]} + IMPORT_ERROR = "%s: %s" % (type(e).__name__, str(e)[:200]) + + +def _syntax_error(src): + """None when src compiles as an expression; the SyntaxError or ValueError compile() raises + for it otherwise (what debugpy logs at every hit). Anything else is this process's limit.""" + try: + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + compile(src, "", "eval") + return None + except (SyntaxError, ValueError) as e: + return e + except Exception as e: # noqa: BLE001 RecursionError, MemoryError, ...: not a property of the text + raise Decline("the check could not compile it here (%s)" % type(e).__name__) + + +def _tree(src): + """ast.parse(src, mode="eval"), or None when it is a syntax error; Decline on anything else.""" + try: + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + return ast.parse(src, mode="eval") + except (SyntaxError, ValueError): + return None + except Exception as e: # noqa: BLE001 + raise Decline("the check could not parse it here (%s)" % type(e).__name__) + + +class _Counting: + """Iterator over a string that remembers how far pydevd's matcher read.""" + + def __init__(self, s): + self.s, self.pos = s, 0 + + def __iter__(self): + return self + + def __next__(self): + if self.pos >= len(self.s): + raise StopIteration + self.pos += 1 + return self.s[self.pos - 1] + + +def split(m): + """The message as pydevd splits it, by pydevd's own brace matcher: ("text", s), ("group", raw) + and ("empty", raw) parts. None when its braces do not balance (pydevd's fallback).""" + it, parts, text = _Counting(m), [], [] + for c in it: + if c != "{": + text.append(c) + continue + start = it.pos + try: + nested(it) + except SyntaxError: + return None + raw = m[start:it.pos - 1] + if text: + parts.append(("text", "".join(text))) + text = [] + parts.append(("group" if raw.strip() else "empty", raw)) + if text: + parts.append(("text", "".join(text))) + return parts + + +def join(parts): + return "".join("{" + v + "}" if k in ("group", "empty") else v for k, v in parts) + + +def template_of(parts): + return "".join(v if k == "text" else "%s" for k, v in parts if k != "empty") + + +_DIRECTIVE = re.compile(r"%[^A-Za-z%]*") +_DIGITS = re.compile(r"\d+") + + +def _bound_template(template): + total = 0 + for directive in _DIRECTIVE.findall(template): + for run in _DIGITS.findall(directive): + if len(run) > MAX_DIGITS: + raise Decline("a %%-directive width or precision of more than %d digits is not formatted" % MAX_DIGITS) + total += int(run) + if total > MAX_WIDTH_SUM: + raise Decline("the %%-directive widths and precisions add up to more than %d" % MAX_WIDTH_SUM) + + +def cannot_run(n): + """None when pydevd's expression n can run for some values; else why it cannot run for any.""" + err = _syntax_error(n) + if err is not None: + return {"kind": "compile", "text": str(err)} + tree = _tree(n) + if tree is None: + raise Decline("compile() and ast.parse() disagreed") + t = tree.body + if (isinstance(t, ast.BinOp) and isinstance(t.op, ast.Mod) and isinstance(t.left, ast.Constant) + and isinstance(t.left.value, str) and isinstance(t.right, ast.Tuple)): + if any(isinstance(e, ast.Starred) for e in t.right.elts): + return None # how many elements there are is a value: left to the hit + _bound_template(t.left.value) + try: + t.left.value % ((1,) * len(t.right.elts)) # 1 satisfies every conversion and every * + except (TypeError, ValueError) as e: + return {"kind": "percent", "text": str(e)} + except Exception as e: # noqa: BLE001 + raise Decline("the check could not format the template here (%s)" % type(e).__name__) + return None + + +def assigns(tree): + return sorted({x.target.id for x in ast.walk(tree) + if isinstance(x, ast.NamedExpr) and isinstance(x.target, ast.Name)}) + + +def field_form(raw): + """f{raw}: the same field as an f-string, when CPython reads it as exactly one field.""" + for q in ("'", '"', "'''", '"""'): + if sys.version_info < (3, 12) and q in raw: + continue # before PEP 701 the field sits inside one string literal: it cannot hold the delimiter + src = "f" + q + "{" + raw + "}" + q + tree = _tree(src) + if tree is None or _syntax_error(src) is not None: + continue + vals = tree.body.values if isinstance(tree.body, ast.JoinedStr) else None + if vals and isinstance(vals[-1], ast.FormattedValue) and all( + isinstance(v, ast.Constant) for v in vals[:-1]) and len(vals) <= 2: + return src + return None + + +def _fails(why, **extra): + out = {"status": "fails", "cause": why} + out.update(extra) + return out + + +def check(m): + if conv is None: + return {"status": "unchecked", "cause": "debugpy's conversion could not be imported (%s)" % IMPORT_ERROR} + if len(m) > MAX_MESSAGE: + return {"status": "unchecked", "cause": "the message is longer than %d characters" % MAX_MESSAGE} + try: + n = conv(m) + if n == repr("Unbalanced braces in: %s" % (m,)): + return _fails({"kind": "unbalanced", "text": "Unbalanced braces in: %s" % (m,)}) + why = cannot_run(n) + if why is None: + out = {"status": "runs"} + tree = _tree(n) + if tree is None: + raise Decline("compile() and ast.parse() disagreed") + names = assigns(tree) + if names: + out["assigns"] = names + # A walrus an f-string would read as a format spec ({x:=10}): name that reading. + readings = {} + for k, v in split(m) or []: + if k != "group": + continue + group_tree = _tree(conv("{" + v + "}")) + if group_tree is None or not assigns(group_tree): + continue + f = field_form(v) + if f is not None and _tree(f).body.values[-1].format_spec is not None: + readings[v] = "{" + f + "}" + if readings: + out["fstringReading"] = readings + return out + parts = split(m) + if parts is None or conv(join(parts)) != n: + return _fails(why, note="split") + new, changed = [], [] + for k, v in parts: + if k == "group" and _syntax_error(conv("{" + v + "}")) is not None: + f = field_form(v) + if f is None: + return _fails(why, group=v) + new.append(("group", f)) + changed.append(v) + else: + new.append((k, v)) + percent = False + n2 = conv(join(new)) + if cannot_run(n2) is not None: + new = [(k, v.replace("%", "%%")) if k == "text" else (k, v) for k, v in new] + percent = True + n2 = conv(join(new)) + if cannot_run(n2) is not None: + return _fails(why) + # Validated by CPython's own parser: the same template (with % doubled where it was), + # every untouched group's expression unchanged, every replaced one an f-string. + tree2 = _tree(n2) + if tree2 is None: + raise Decline("compile() and ast.parse() disagreed") + t2 = tree2.body + groups = sum(1 for k, _ in new if k == "group") + if groups and not (isinstance(t2, ast.BinOp) and isinstance(t2.left, ast.Constant) + and t2.left.value == template_of(new) and isinstance(t2.right, ast.Tuple) + and len(t2.right.elts) == groups): + return _fails(why, note="validation") + gi = 0 + for (k, v), (_, v2) in zip(parts, new): + if k != "group": + continue + e2 = t2.right.elts[gi] + if v2 == v: + single = _tree("(" + v.strip() + "\n,)") + if not (single is not None and isinstance(single.body, ast.Tuple) and len(single.body.elts) == 1 + and ast.dump(single.body.elts[0]) == ast.dump(e2)): + return _fails(why, note="validation") + elif not isinstance(e2, ast.JoinedStr): + return _fails(why, note="validation") + gi += 1 + out = {"status": "rewritten", "cause": why, "wire": join(new), "groups": changed, "percentDoubled": percent} + names = assigns(tree2) + if names: + out["assigns"] = names + return out + except Decline as e: + return {"status": "unchecked", "cause": str(e)} + except BaseException as e: # noqa: BLE001 one message never ends the checker + return {"status": "unchecked", "cause": "the check failed here (%s)" % type(e).__name__} + + +def _image(pid): + """The executable of a local process, as the OS reports it (None when it cannot say).""" + if sys.platform == "win32": + import ctypes + from ctypes import wintypes + k = ctypes.WinDLL("kernel32", use_last_error=True) + k.OpenProcess.restype = wintypes.HANDLE + h = k.OpenProcess(0x1000, False, int(pid)) # PROCESS_QUERY_LIMITED_INFORMATION + if not h: + return None + try: + buf, size = ctypes.create_unicode_buffer(32768), wintypes.DWORD(32768) + ok = k.QueryFullProcessImageNameW(h, 0, buf, ctypes.byref(size)) + return buf.value if ok else None + finally: + k.CloseHandle(h) + link = "/proc/%d/exe" % int(pid) + if os.path.exists(link): + return os.path.realpath(link) + return None + + +def same_interpreter(pid): + image = _image(pid) + if image is None: + return {"image": None, "same": None} + ours = {os.path.normcase(os.path.realpath(p)) + for p in (sys.executable, getattr(sys, "_base_executable", None)) if p} + return {"image": image, "same": os.path.normcase(os.path.realpath(image)) in ours} + + +def serve(): + for line in sys.stdin: + try: + req = json.loads(line) + op = req.get("op") + if op == "check": + res = check(req["m"]) + res.update(VERSIONS) + elif op == "sameInterpreter": + res = same_interpreter(req["pid"]) + else: + res = {"error": "unknown op"} + except BaseException as e: # noqa: BLE001 + res = {"error": "%s: %s" % (type(e).__name__, str(e)[:200])} + sys.stdout.write(json.dumps(res, ensure_ascii=True) + "\n") + sys.stdout.flush() + + +if __name__ == "__main__": + serve() +`; + +/** How the core starts the checker: on the run's adapter executable (the program's interpreter). */ +export const PYTHON_LOGPOINT_CHECKER: LogMessageCheckerSpec = { + key: 'debugpy-logpoint', + args: ['-X', 'utf8', '-c', PYTHON_LOGPOINT_CHECKER_SOURCE] +}; + +/** + * Launch keys with which debugpy runs the program on another interpreter, or + * with other interpreter flags, than its own (`debugpy/adapter/clients.py`: + * `python` — a string or a vector — the deprecated `pythonPath`, and + * `pythonArgs`). The checker runs on the adapter's interpreter, so a launch + * that names any of them is not checked. + */ +function ownInterpreterKey(config: Readonly> | undefined): string | undefined { + if (!config) { + return undefined; + } + const present = (value: unknown): boolean => + typeof value === 'string' ? value.length > 0 : Array.isArray(value) ? value.length > 0 : value !== undefined && value !== null; + for (const key of ['python', 'pythonPath', 'pythonArgs']) { + if (present(config[key])) { + return key; + } + } + return undefined; +} + +const unchecked = (reason: string): LogMessageVerdict => ({ status: 'unchecked', note: `Not checked (${reason}); sent as written.` }); + +const quote = (text: string): string => `\`${text}\``; + +function listOf(items: string[]): string { + return items.length <= 1 ? items.join('') : `${items.slice(0, -1).join(', ')} and ${items[items.length - 1]}`; +} + +interface CheckerCause { + kind: 'compile' | 'percent' | 'unbalanced'; + text: string; +} + +interface CheckerAnswer { + status?: unknown; + cause?: unknown; + wire?: unknown; + groups?: unknown; + percentDoubled?: unknown; + assigns?: unknown; + fstringReading?: unknown; + group?: unknown; + python?: unknown; + debugpy?: unknown; + error?: unknown; +} + +const isStringArray = (value: unknown): value is string[] => Array.isArray(value) && value.every((item) => typeof item === 'string'); + +function causeOf(value: unknown): CheckerCause | undefined { + if (typeof value !== 'object' || value === null) { + return undefined; + } + const { kind, text } = value as { kind?: unknown; text?: unknown }; + return (kind === 'compile' || kind === 'percent' || kind === 'unbalanced') && typeof text === 'string' + ? { kind, text } + : undefined; +} + +/** What the message as written does at every hit, in the checker's words. */ +function asWritten(cause: CheckerCause): string { + switch (cause.kind) { + case 'compile': + return `it does not compile, so as written every hit logs ${quote(cause.text)}`; + case 'percent': + return `its text cannot be formatted with \`%\` for any values (with every value 1, CPython's \`%\` says ${quote(cause.text)}; real values can fail with another message), so as written every hit logs an error`; + case 'unbalanced': + return `its braces do not balance, so as written every hit logs ${quote(cause.text)} instead of evaluating it`; + } +} + +/** + * The assignment sentence (issue #1349's review): an assignment expression in + * the evaluated text is what the AST shows, not what a hit does — it may sit + * in a branch that never runs or in a nested scope. + */ +function assignmentNote(names: string[], python: string, readings: Record | undefined): string { + const major = /^(\d+)\.(\d+)/.exec(python); + const writesThrough = major !== null && (Number(major[1]) > 3 || (Number(major[1]) === 3 && Number(major[2]) >= 13)); + const reading = readings && Object.keys(readings).length > 0 + ? ' ' + Object.entries(readings) + .map(([group, form]) => `As an f-string field, ${quote(`{${group}}`)} would be a format spec instead: ${quote(form)}.`) + .join(' ') + : ''; + return ( + `The message contains an assignment expression (binding ${listOf(names.map(quote))}), possibly in a nested scope: ` + + 'debugpy evaluates it as Python, so where it runs it assigns' + + (writesThrough ? `, and on Python ${python} that can change the running function's own variable.` : '.') + + reading + ); +} + +function authority(python: string, debugpy: string, child: boolean): string { + return `Checked by compiling with Python ${python} and debugpy ${debugpy}, the interpreter ${ + child ? 'this child runs on' : 'this launch runs the program on' + }; this check did not execute a hit.`; +} + +/** The checker's answer as a verdict for the core, with the sentence the answers carry. */ +export function verdictFromCheckerAnswer(message: string, value: unknown, child: boolean): LogMessageVerdict { + if (typeof value !== 'object' || value === null) { + return unchecked("the checker's answer was not understood"); + } + const answer = value as CheckerAnswer; + if (typeof answer.error === 'string') { + return unchecked(`the checker answered an error: ${answer.error}`); + } + const python = typeof answer.python === 'string' ? answer.python : 'unknown'; + const debugpy = typeof answer.debugpy === 'string' ? answer.debugpy : 'unknown'; + const assigns = isStringArray(answer.assigns) && answer.assigns.length > 0 ? answer.assigns : undefined; + const readings = typeof answer.fstringReading === 'object' && answer.fstringReading !== null + ? Object.fromEntries( + Object.entries(answer.fstringReading as Record).filter((entry): entry is [string, string] => typeof entry[1] === 'string') + ) + : undefined; + switch (answer.status) { + case 'runs': + return assigns + ? { status: 'runs', assigns, note: assignmentNote(assigns, python, readings) } + : { status: 'runs' }; + case 'rewritten': { + const cause = causeOf(answer.cause); + if ( + cause === undefined || typeof answer.wire !== 'string' || answer.wire === message || + !isStringArray(answer.groups) || typeof answer.percentDoubled !== 'boolean' + ) { + return unchecked("the checker's answer was not understood"); + } + const groups = answer.groups; + const what = groups.length > 0 + ? `debugpy reads ${listOf(groups.map((g) => quote(`{${g}}`)))} as ${groups.length === 1 ? 'a plain Python expression' : 'plain Python expressions'}, and ${asWritten(cause)}.` + : `debugpy cannot run this message as written: ${asWritten(cause)}.`; + const how = [ + groups.length > 0 ? (groups.length === 1 ? 'the same field as an f-string' : 'each the same field as an f-string') : undefined, + answer.percentDoubled ? "with the text's `%` doubled, which keeps each literal `%` if the fields evaluate" : undefined + ].filter((part): part is string => part !== undefined).join(', '); + const note = [ + what, + `Sent as ${quote(answer.wire)}, ${how}.`, + authority(python, debugpy, child), + ...(assigns ? [assignmentNote(assigns, python, undefined)] : []) + ].join(' '); + return { + status: 'rewritten', + wire: answer.wire, + groups, + percentDoubled: answer.percentDoubled, + note, + ...(assigns ? { assigns } : {}) + }; + } + case 'fails': { + const cause = causeOf(answer.cause); + if (cause === undefined) { + return unchecked("the checker's answer was not understood"); + } + const group = typeof answer.group === 'string' ? answer.group : undefined; + const note = + `debugpy cannot run this message as written: ${asWritten(cause)}.` + + (cause.kind === 'unbalanced' + ? '' + : ` This check found no form that keeps the message's other parts${group !== undefined ? ` (${quote(`{${group}}`)} has no f-string form here)` : ''}.`) + + ` Sent as written. ${authority(python, debugpy, child)}`; + return { status: 'fails', note, ...(group !== undefined ? { group } : {}) }; + } + case 'unchecked': + return unchecked(typeof answer.cause === 'string' ? answer.cause : 'the checker gave no reason'); + default: + return unchecked("the checker's answer was not understood"); + } +} + +/** + * The Python policy's `validateLogMessage` once the core can say where the + * message runs. Every path that cannot establish the interpreter, its flags + * or the converter ends in `unchecked`: the message is then sent as written. + */ +export async function checkPythonLogMessage(message: string, checker: LogMessageChecker): Promise { + const key = ownInterpreterKey(checker.launchConfig); + if (key !== undefined) { + return unchecked(`the launch names its own interpreter or interpreter arguments (${key}), and this check runs on the adapter's interpreter`); + } + if (checker.child) { + const pid = checker.child.configuration.subProcessId; + if (typeof pid !== 'number' || !Number.isInteger(pid) || pid <= 0) { + return unchecked("the child's report does not name its process"); + } + const same = await checker.ask(PYTHON_LOGPOINT_CHECKER, { op: 'sameInterpreter', pid }); + if (!same.ok) { + return unchecked(same.cause); + } + const { image, same: isSame } = (same.value ?? {}) as { image?: unknown; same?: unknown }; + if (isSame !== true) { + return unchecked( + typeof image === 'string' && image.length > 0 + ? `the child runs on ${image}, not on the interpreter that was checked` + : "the child's executable could not be looked up" + ); + } + } + const reply = await checker.ask(PYTHON_LOGPOINT_CHECKER, { op: 'check', m: message }); + if (!reply.ok) { + return unchecked(reply.cause); + } + return verdictFromCheckerAnswer(message, reply.value, checker.child !== undefined); +} diff --git a/packages/shared/src/models/index.ts b/packages/shared/src/models/index.ts index fa20a7fd2..27dea12c8 100644 --- a/packages/shared/src/models/index.ts +++ b/packages/shared/src/models/index.ts @@ -2,6 +2,7 @@ * Session-related data models */ import { DebugProtocol } from '@vscode/debugprotocol'; +import type { LogMessageVerdict } from '../interfaces/adapter-policy.js'; /** * Custom launch arguments interface extending DebugProtocol.LaunchRequestArguments @@ -259,8 +260,18 @@ export interface Breakpoint { line: number; /** Conditional expression (if any) */ condition?: string; - /** Logpoint: log this interpolated message instead of pausing (DAP logMessage) */ + /** Logpoint: log this interpolated message instead of pausing (DAP logMessage), as the caller wrote it */ logMessage?: string; + /** + * What goes to the adapter in place of `logMessage` (issues #1334, #1349): + * set only while the run whose check produced it lasts — the policy's + * checked repair of a message that cannot run as written. Cleared by the + * next launch, restart or attach before anything is sent. Never shown as + * such: answers project it as `logMessageSent`. + */ + wireLogMessage?: string; + /** The policy's check of `logMessage` for the current run (issues #1334, #1349); absent when nothing checked it. */ + logMessageVerdict?: LogMessageVerdict; /** Suspend policy: 'all' suspends all threads (default), 'thread' only suspends the event thread */ suspendPolicy?: 'all' | 'thread'; /** Whether the breakpoint is verified */ diff --git a/packages/shared/src/utils/to-source-breakpoint.ts b/packages/shared/src/utils/to-source-breakpoint.ts index 41f3b11f3..4fb5c73fd 100644 --- a/packages/shared/src/utils/to-source-breakpoint.ts +++ b/packages/shared/src/utils/to-source-breakpoint.ts @@ -14,19 +14,54 @@ export interface BreakpointFields { line: number; condition?: string; logMessage?: string; + /** + * The checked repair the adapter receives in place of `logMessage` (issues + * #1334, #1349). The session store keeps the caller's text in `logMessage`; + * a record that leaves the store for the worker carries the wire there + * instead (`toInitialBreakpoint`), so the worker never sees this field. + */ + wireLogMessage?: string; /** Java/JDI-only suspend policy, passed through as a non-standard field */ suspendPolicy?: 'all' | 'thread'; } export function toSourceBreakpoint(bp: BreakpointFields): DebugProtocol.SourceBreakpoint { + const logMessage = bp.wireLogMessage ?? bp.logMessage; return { line: bp.line, ...(bp.condition !== undefined ? { condition: bp.condition } : {}), - ...(bp.logMessage !== undefined ? { logMessage: bp.logMessage } : {}), + ...(logMessage !== undefined ? { logMessage } : {}), ...(bp.suspendPolicy !== undefined ? { suspendPolicy: bp.suspendPolicy } : {}), }; } +/** A stored breakpoint as it leaves the session store for the worker: the fields the worker's own mapping reads. */ +export interface InitialBreakpoint { + id?: string; + file: string; + line: number; + condition?: string; + logMessage?: string; + suspendPolicy?: 'all' | 'thread'; +} + +/** + * The one place a stored breakpoint is copied for the proxy worker — a + * launch's initial set, a child's adoption (issues #1334, #1349): the wire, + * when the run's check produced one, goes in `logMessage`, which is the field + * the worker and the IPC parser carry to the adapter unchanged. + */ +export function toInitialBreakpoint(bp: BreakpointFields & { id?: string; file: string }): InitialBreakpoint { + return { + id: bp.id, + file: bp.file, + line: bp.line, + condition: bp.condition, + logMessage: bp.wireLogMessage ?? bp.logMessage, + suspendPolicy: bp.suspendPolicy, + }; +} + /** * The wire form a given adapter must receive (issue #850): the policy's * toWireBreakpoint when it declares one (js-debug compiles logpoints into diff --git a/skills/debugging/references/python.md b/skills/debugging/references/python.md index 8f4aac062..9c592494b 100644 --- a/skills/debugging/references/python.md +++ b/skills/debugging/references/python.md @@ -69,7 +69,7 @@ Shorthand: `create_debug_session { "language": "python", "host": "127.0.0.1", "p - **Set breakpoints on executable lines** (assignments, calls, returns). Comments, blank lines, and bare `def`/`class` lines misbehave. - **evaluate_expression** runs in debugpy's `variables` (watch-style) context by default. Reads and arithmetic are reliable; whether mutations like `x = 5` take effect depends on debugpy — verify with a follow-up evaluate before relying on one. Collections are truncated at 300 items. - **Output capture works for Python** (`redirectOutput`): `print()` and stderr land in `get_output` entries, readable during and after the run until the session closes. -- Logpoints work: `set_breakpoint` with `logMessage: "x={x}"` logs interpolated values to `get_output` without pausing. Each hit costs about 24.7 µs (2.5% of a core at 1,000 hits/s), and any logpoint in a function slows that whole function by 58× on Python 3.13 + debugpy (`sys.monitoring`) — keep logpoints off tight loops. When hits outrun debugpy's delivery rate (measured at 3,200–4,400 lines/s during a run, ~6,000 lines/s draining after), lines still queued at program exit are lost and the end answer does not say so (issue #1265). Full measurements: [docs/tool-reference.md#logpoints](https://github.com/debugmcp/mcp-debugger/blob/main/docs/tool-reference.md#logpoints). +- Logpoints work: `set_breakpoint` with `logMessage: "x={x}"` logs interpolated values to `get_output` without pausing. A field is an expression in the program's language. For Python, f-string field syntax (`{x!r}`, `{total:.2f}`, `{x=}`) is accepted where the server checked the message on the program's own interpreter, which is a launched session; the answer then carries `logMessageSent` (what debugpy received, e.g. `{f'{x!r}'}`) and `logMessageCheck` (why). Elsewhere (an attach, a launch naming its own `python`) the message goes to debugpy as written, which evaluates each field as a plain expression, and the answer says it was not checked. debugpy's own reading wins whenever it can run the message: `{{x}}` is a set and `%%` is `%`. Nothing is refused; a message that runs is never changed. Each hit costs about 24.7 µs (2.5% of a core at 1,000 hits/s), and any logpoint in a function slows that whole function by 58× on Python 3.13 + debugpy (`sys.monitoring`) — keep logpoints off tight loops. When hits outrun debugpy's delivery rate (measured at 3,200–4,400 lines/s during a run, ~6,000 lines/s draining after), lines still queued at program exit are lost and the end answer does not say so (issue #1265). Full measurements: [docs/tool-reference.md#logpoints](https://github.com/debugmcp/mcp-debugger/blob/main/docs/tool-reference.md#logpoints). - **Child processes are debug sessions by default.** debugpy's sub-process debugging is on: each Python child the program starts (`subprocess`, `multiprocessing`, pytest-xdist workers) becomes a child debug session — `list_debug_sessions` lists it with `parentSessionId`, it stops on this session's breakpoints, and `wait_for_stop` on this session reports the child's stop with `sessionId` naming the child (inspect and step with that id) and `children` listing the tree; a child can still be waited on by its own id. `dapLaunchArgs: { subProcess: false }` opts a launch out (the children run undebugged; the answer's warning says so); an attach target decides for itself (`python -m debugpy --listen … --configure-subProcess false`). `DEBUG_MCP_MAX_CHILD_SESSIONS=0` turns adoption off server-wide. ## Troubleshooting diff --git a/src/implementations/process-launcher-impl.ts b/src/implementations/process-launcher-impl.ts index aed076841..d734d8867 100644 --- a/src/implementations/process-launcher-impl.ts +++ b/src/implementations/process-launcher-impl.ts @@ -24,6 +24,16 @@ import { OWNER_PID_ARG_PREFIX, SESSION_ID_ARG_PREFIX } from '../utils/proxy-orph */ export const IPC_DRAIN_CAP_MS = 1000; +/** + * The directory the proxy worker runs in — and so the directory an adapter + * the worker spawns without a cwd of its own inherits. One computation for + * both readers: the launcher below, and the logpoint checker, which runs on + * the adapter's interpreter from the adapter's directory (issue #1334). + */ +export function proxyWorkerCwd(): string { + return path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..'); +} + /** * Proxy process adapter that adds proxy-specific functionality * Does NOT extend ProcessAdapter to avoid double message handling @@ -564,7 +574,7 @@ export class ProxyProcessLauncherImpl implements IProxyProcessLauncher { // Ensure the proxy runs from the project root directory, not VS Code's directory // This is critical for IPC and path resolution to work correctly - const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..'); + const projectRoot = proxyWorkerCwd(); // Log critical environment variables being passed to proxy worker console.log('[ProxyProcessLauncher] Environment check for proxy worker:', { diff --git a/src/proxy/adapter-cwd.ts b/src/proxy/adapter-cwd.ts new file mode 100644 index 000000000..78874e614 --- /dev/null +++ b/src/proxy/adapter-cwd.ts @@ -0,0 +1,21 @@ +/** + * The working directory a spawned debug adapter gets, decided in one place + * for the proxy worker that spawns it and for the logpoint checker that must + * run where it runs (issue #1334): the policy's own cwd when it names one; + * otherwise, in container mode, the workspace root when that directory + * exists, so relative paths in DAP launch arguments resolve against the + * mounted project rather than /app (a kubectl-debug ephemeral container + * mounts nothing there, and a nonexistent cwd fails with an opaque ENOENT, + * issue #332); otherwise none, and the adapter inherits the worker's. + */ +export function adapterSpawnCwd( + policyCwd: string | undefined, + env: NodeJS.ProcessEnv, + exists: (dir: string) => boolean +): string | undefined { + if (policyCwd) { + return policyCwd; + } + const workspaceRoot = env.MCP_WORKSPACE_ROOT; + return workspaceRoot && exists(workspaceRoot) ? workspaceRoot : undefined; +} diff --git a/src/proxy/dap-proxy-worker.ts b/src/proxy/dap-proxy-worker.ts index be1d656ba..cd968bfcb 100644 --- a/src/proxy/dap-proxy-worker.ts +++ b/src/proxy/dap-proxy-worker.ts @@ -5,6 +5,7 @@ import { ChildProcess } from 'child_process'; import { launchConfigIsAttach } from './proxy-config.js'; +import { adapterSpawnCwd } from './adapter-cwd.js'; import { dapSourcePath } from '../utils/dap-source.js'; import { existsSync } from 'fs'; import path from 'path'; @@ -661,12 +662,10 @@ export class DapProxyWorker { // directory actually exists: in a kubectl-debug ephemeral container // nothing mounts /workspace, and spawning with a nonexistent cwd fails // with an opaque ENOENT (issue #332). - if ( - process.env.MCP_WORKSPACE_ROOT && - !spawnConfig.cwd && - existsSync(process.env.MCP_WORKSPACE_ROOT) - ) { - spawnConfig.cwd = process.env.MCP_WORKSPACE_ROOT; + // The same decision the logpoint checker reads (adapter-cwd.ts). + const adapterCwd = adapterSpawnCwd(spawnConfig.cwd, process.env, existsSync); + if (adapterCwd !== undefined) { + spawnConfig.cwd = adapterCwd; } const spawnResult = await this.processManager!.spawn({ diff --git a/src/server.ts b/src/server.ts index aa1e3fa31..ef666b2ab 100644 --- a/src/server.ts +++ b/src/server.ts @@ -202,11 +202,18 @@ export class DebugMcpServer implements ToolContext { // A policy that compiles logpoints itself (js-debug, issue #850) checks // the message up front, so a syntax error is refused here — like an // expectedContent mismatch — instead of surfacing only in the adapter's - // stderr as an unbound breakpoint (issue #853). + // stderr as an unbound breakpoint (issue #853). Only that policy's own + // synchronous refusal counts here: a check that needs the program's + // runtime (Python, issue #1334) runs in the session layer, with the run's + // checker, and refuses nothing. const compileCheck = (): void => { - const problem = logMessage !== undefined ? policy.validateLogMessage?.(logMessage, condition) : undefined; - if (problem) { - throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Invalid logpoint: ${problem}`); + const verdict = logMessage !== undefined ? policy.validateLogMessage?.(logMessage, condition) : undefined; + if (verdict instanceof Promise) { + verdict.catch(() => undefined); + return; + } + if (verdict?.status === 'refused') { + throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Invalid logpoint: ${verdict.reason}`); } }; diff --git a/src/server/handlers/breakpoint-tools.ts b/src/server/handlers/breakpoint-tools.ts index 08817347e..8a9010526 100644 --- a/src/server/handlers/breakpoint-tools.ts +++ b/src/server/handlers/breakpoint-tools.ts @@ -5,6 +5,7 @@ import { ProtocolError, ProtocolErrorCode } from '@modelcontextprotocol/server'; import { ContentAddressingNotSupportedError } from '../../errors/debug-errors.js'; import { buildAttachBreakpointScopeWarning } from '../../session/breakpoints/launch-warnings.js'; +import { publicBreakpoint } from '../../session/breakpoints/logpoint-checks.js'; import { Breakpoint, FunctionBreakpoint, SessionState } from '@debugmcp/shared'; import { BP_ADDRESSING_ENV_KEY, @@ -228,6 +229,7 @@ async function setLineBreakpointBranch(ctx: ToolContext, args: WithSessionId): P : undefined; const recordMessage = messageBesideWarning(breakpoint); + const shown = publicBreakpoint(breakpoint); // The stale-build sentence follows a snap on purpose: a move onto an // unlikely line is the symptom, the old build its likely cause. const warnings = [ @@ -246,6 +248,11 @@ async function setLineBreakpointBranch(ctx: ToolContext, args: WithSessionId): P content: context?.lineContent, verified: breakpoint.verified, logMessage: breakpoint.logMessage, + // What the run's logpoint check found (issue #1334): the message the + // adapter received when it is not the one written, and the check's + // sentence when it has one. A message that runs as written adds nothing. + logMessageSent: shown.logMessageSent, + logMessageCheck: shown.logMessageCheck, message: snapWarning || breakpoint.message || `${breakpoint.logMessage !== undefined ? 'Logpoint' : 'Breakpoint'} set at ${breakpoint.file}:${breakpoint.line}`, // Warn on adapter validation messages, sync failures, snaps, // and unknown logpoint support @@ -313,7 +320,9 @@ export const listBreakpointsTool: ToolHandler = async (ctx, args) => { const why = [debuggerOffNote(ctx, args.sessionId, !anyUnverified), scopeWarning].filter(Boolean).join(' '); return jsonResult({ success: true, - breakpoints, + // The caller's logMessage, with logMessageSent beside it when the + // adapter received another (issue #1334); never the record's bookkeeping. + breakpoints: breakpoints.map(publicBreakpoint), count: breakpoints.length, ...(args.file === undefined ? { functionBreakpoints, functionCount: functionBreakpoints.length } @@ -377,7 +386,7 @@ export const removeBreakpointTool: ToolHandler = async (ctx, args) => { } return jsonResult({ success: true, - removed, + removed: removed.map((record) => ('functionName' in record ? record : publicBreakpoint(record))), message: `Removed ${removed.length} breakpoint(s)`, ...(functionDisclosure ?? {}), warning diff --git a/src/server/tool-schemas.ts b/src/server/tool-schemas.ts index 97f30ebac..f866edba8 100644 --- a/src/server/tool-schemas.ts +++ b/src/server/tool-schemas.ts @@ -219,7 +219,7 @@ export function buildToolDefinitions(options: BuildToolDefinitionsOptions): Tool { name: 'create_debug_session', description: 'Create a new debugging session. Passing port, processId or an adapterConfig that names a target (a debugger URI: vmServiceUri, websocketAddress, vmServiceInfoFile; or a Flutter deviceId, for an app running on an Android device) attaches to a running process in the same call, with every attach argument attach_to_process takes (host alone does not); omit them for launch mode. Attaching requests a pause by default (stopOnEntry, see attach_to_process); the answer\'s state and warning say whether one was requested and whether it landed', inputSchema: { type: 'object', properties: { language: { type: 'string', enum: supportedLanguages, description: 'Programming language for debugging' }, name: { type: 'string', description: 'Optional session name' }, executablePath: {type: 'string', description: 'Path to language executable (optional, will auto-detect if not provided)'}, host: { type: 'string', description: 'Attach mode only: host to attach to (the adapter defaults it, usually 127.0.0.1). Does not trigger attach mode by itself' }, port: { type: 'number', description: 'Debug port to attach to (triggers attach mode)' }, processId: { type: ['number', 'string'], description: 'Process ID for local attach, language-specific (triggers attach mode)' }, sourcePaths: { type: 'array', items: { type: 'string' }, description: 'Attach mode only: source paths for code mapping' }, justMyCode: { type: 'boolean', description: 'Attach mode only: only debug user code (skip library code)' }, breakOnExceptions: { type: 'string', enum: ['uncaught', 'all', 'none'], description: 'Attach mode only: break when exceptions are thrown: "uncaught" pauses at uncaught exceptions at the crash site; "all" also pauses on caught/raised exceptions (language-dependent). Default "none" — attach sessions never apply a language default (unlike launch)' }, stopOnEntry: { type: 'boolean', description: 'Attach mode only: same as attach_to_process.stopOnEntry — omitted means true, a pause is requested after attach (it can land late, reported as pending:true). Pass false to attach to a live service without stopping it' }, timeout: { type: 'number', description: 'Attach mode only: connection timeout in milliseconds, forwarded as-is; js-debug honours it (its own default is 10 s) and COBOL uses it as its manifest-build budget, the other adapters ignore it. A value longer than verifyTimeout means the verify deadline is what you hit' }, verifyTimeout: { type: 'number', description: 'Attach mode only: how long to wait (ms) for the debugger to report at least one thread after attaching before failing the attach (default: 20000, max: 600000)' }, adapterConfig: { type: 'object', description: 'Attach mode only: adapter-specific attach configuration merged into the attach config (see attach_to_process). Triggers attach mode when it names a debugger URI (vmServiceUri, websocketAddress) or vmServiceInfoFile', additionalProperties: true } }, required: ['language'] } }, { name: 'list_supported_languages', description: 'List all supported debugging languages with metadata', inputSchema: { type: 'object', properties: {} } }, { name: 'list_debug_sessions', description: 'List all active debugging sessions. Paused sessions include lastStop with the reason for the most recent stop (e.g. "breakpoint" vs "exception")', inputSchema: { type: 'object', properties: {} } }, - { name: 'set_breakpoint', description: `Set a breakpoint. Setting breakpoints on non-executable lines (structural, declarative) may lead to unexpected behavior. A breakpoint can answer verified: false before the launch, or until the module or class holding its line is loaded; that is normal.${addressingScopeSentence}${snapSentence}`, inputSchema: { type: 'object', properties: { sessionId: { type: 'string' }, file: { type: 'string', description: 'Path to the source file or Java FQCN. For Java, passing a fully-qualified class name (e.g. "com.example.MyClass" or "com.example.Outer$Inner") is preferred — it works reliably with all classloaders including custom classloaders. Alternatively, use absolute file paths.' }, line: { type: 'number', description: 'Line number where to set breakpoint. Executable statements (assignments, function calls, conditionals, returns) work best. Structural lines (function/class definitions), declarative lines (imports), or non-executable lines (comments, blank lines) may cause unexpected stepping behavior' }, ...setBreakpointExtraProps, condition: { type: 'string', description: 'Optional expression: only break (or log) when it evaluates truthy' }, logMessage: { type: 'string', description: 'Create a logpoint: instead of pausing, log this message when the line is hit. Expressions in {curly braces} are interpolated (e.g. "order={orderId} total={total}"). Messages arrive in get_output without pausing, but each hit costs time (24.7 µs in Python to 4.9 ms in Dart), so logpoints are not for tight loops; and in Python, JavaScript and Dart a function that holds a line breakpoint of any kind, a logpoint included, runs slower as a whole while it holds it. Supported by the Python, JavaScript, Go, Rust, C/C++, COBOL ({WS-NAME} data references), Dart and mock adapters; not by Java, .NET, or Ruby' }, suspendPolicy: { type: 'string', enum: ['all', 'thread'], description: 'Suspend policy when breakpoint is hit: "all" suspends all threads (default), "thread" only suspends the event thread. Only supported by the Java/JDI adapter.' } }, required: setBreakpointRequired } }, + { name: 'set_breakpoint', description: `Set a breakpoint. Setting breakpoints on non-executable lines (structural, declarative) may lead to unexpected behavior. A breakpoint can answer verified: false before the launch, or until the module or class holding its line is loaded; that is normal.${addressingScopeSentence}${snapSentence}`, inputSchema: { type: 'object', properties: { sessionId: { type: 'string' }, file: { type: 'string', description: 'Path to the source file or Java FQCN. For Java, passing a fully-qualified class name (e.g. "com.example.MyClass" or "com.example.Outer$Inner") is preferred — it works reliably with all classloaders including custom classloaders. Alternatively, use absolute file paths.' }, line: { type: 'number', description: 'Line number where to set breakpoint. Executable statements (assignments, function calls, conditionals, returns) work best. Structural lines (function/class definitions), declarative lines (imports), or non-executable lines (comments, blank lines) may cause unexpected stepping behavior' }, ...setBreakpointExtraProps, condition: { type: 'string', description: 'Optional expression: only break (or log) when it evaluates truthy' }, logMessage: { type: 'string', description: 'Create a logpoint: instead of pausing, log this message when the line is hit. Expressions in {curly braces} are interpolated (e.g. "order={orderId} total={total}"). A field is an expression in the program\'s language. For Python, f-string field syntax ({x!r}, {total:.2f}, {x=}) is accepted where the server checked the message on the program\'s own interpreter, which is a launched session: the answer then shows logMessageSent, what debugpy received, and logMessageCheck, what was found. Elsewhere the message goes to debugpy as written, which evaluates each field as a plain expression, and the answer says it was not checked. debugpy\'s own reading wins whenever it can run the message: {{x}} is a set and %% is %. Messages arrive in get_output without pausing, but each hit costs time (24.7 µs in Python to 4.9 ms in Dart), so logpoints are not for tight loops; and in Python, JavaScript and Dart a function that holds a line breakpoint of any kind, a logpoint included, runs slower as a whole while it holds it. Supported by the Python, JavaScript, Go, Rust, C/C++, COBOL ({WS-NAME} data references), Dart and mock adapters; not by Java, .NET, or Ruby' }, suspendPolicy: { type: 'string', enum: ['all', 'thread'], description: 'Suspend policy when breakpoint is hit: "all" suspends all threads (default), "thread" only suspends the event thread. Only supported by the Java/JDI adapter.' } }, required: setBreakpointRequired } }, { name: 'list_breakpoints', description: 'List all breakpoints in a session with their verified state and adapter-assigned ids. Session-global function breakpoints appear separately as functionBreakpoints (omitted when filtering by file). Works before launch (queued, verified=false), while running or paused, and after the program exits', inputSchema: { type: 'object', properties: { sessionId: { type: 'string' }, file: { type: 'string', description: 'Optional: only list breakpoints in this file' } }, required: ['sessionId'] } }, { name: 'remove_breakpoint', description: 'Remove a breakpoint by breakpointId (returned by set_breakpoint / list_breakpoints), by function name, or by file + line (removes all breakpoints at that location). Takes effect immediately while the program is running or paused; also works after the program exits, before a relaunch', inputSchema: { type: 'object', properties: { sessionId: { type: 'string' }, breakpointId: { type: 'string', description: 'Breakpoint id from set_breakpoint or list_breakpoints. Takes precedence over file + line' }, function: { type: 'string', description: 'Alternative addressing: remove all function breakpoints with this symbol name. Applies the same per-language rewrite as set_breakpoint (e.g. a bare Go "main" matches the stored "main.main"); the response reports the effective name as functionName and, when rewritten, the original as requestedName' }, file: { type: 'string', description: 'Alternative addressing: source file path (use together with line)' }, line: { type: 'number', description: 'Alternative addressing: line number (use together with file)' } }, required: ['sessionId'] } }, { name: 'clear_breakpoints', description: 'Remove all breakpoints in a session, or all breakpoints in one file. Clearing zero breakpoints is success. Takes effect immediately while the program is running or paused', inputSchema: { type: 'object', properties: { sessionId: { type: 'string' }, file: { type: 'string', description: 'Optional: only clear breakpoints in this file' } }, required: ['sessionId'] } }, diff --git a/src/session/attach/attach-controller.ts b/src/session/attach/attach-controller.ts index bbb0ff2a3..15d7855b2 100644 --- a/src/session/attach/attach-controller.ts +++ b/src/session/attach/attach-controller.ts @@ -36,6 +36,7 @@ import type { } from '../session-manager-core.js'; import type { AttachContext } from '../operations-context.js'; import type { BreakpointController } from '../breakpoints/breakpoint-controller.js'; +import { logpointChecksField } from '../breakpoints/logpoint-checks.js'; import { failProxySetup, sessionRemovedDuringTeardown } from '../launch/proxy-failure-diagnostics.js'; import type { ProxyLauncher } from '../launch/proxy-launcher.js'; import { recordExceptionArming } from '../launch/launch-arming.js'; @@ -493,7 +494,9 @@ export class AttachController { ...(attachPausePending ? { pending: true } : {}), ...(landing ? landingFields(landing) : {}), ...(snapshot ? { snapshot } : {}), - ...(session.run.attachFootprint ? { attachFootprint: session.run.attachFootprint } : {}) + ...(session.run.attachFootprint ? { attachFootprint: session.run.attachFootprint } : {}), + // What the attach's logpoint check said (issue #1334): not checked, and why. + ...logpointChecksField(session.breakpoints.values()) }; // Surface adapterConfig keys the adapter's attach transform dropped // (issue #450) and keys forwarded to the adapter unrecognized (issue diff --git a/src/session/breakpoints/breakpoint-controller.ts b/src/session/breakpoints/breakpoint-controller.ts index 0189dda24..92e262966 100644 --- a/src/session/breakpoints/breakpoint-controller.ts +++ b/src/session/breakpoints/breakpoint-controller.ts @@ -37,6 +37,7 @@ import type { BreakpointContext } from '../operations-context.js'; import { runFactsOf } from '../run-facts.js'; import { getCurrentPauseIntent } from '../execution/pause-intent.js'; import { buildFunctionBreakpointLaunchWarning, fileLabel } from './launch-warnings.js'; +import { applyLogMessageVerdict, verdictFor } from './logpoint-checks.js'; import { applyBoundLocation, keepHitProven, @@ -206,6 +207,20 @@ export class BreakpointController { newBreakpoint.anchor = bp.anchor; } + // A logpoint set while a run is under way is checked by that run's + // checker before it is stored and sent (issue #1334); one set before any + // run is checked by the launch. The verdict is kept only if the run it + // was asked in still lasts: the next run's own check decides otherwise. + if (bp.logMessage !== undefined) { + const checking = this.ctx.logpointChecker(session); + if (checking) { + const verdict = await verdictFor(this.wirePolicy(session), bp.logMessage, bp.condition, checking.checker); + if (checking.isCurrent()) { + applyLogMessageVerdict(newBreakpoint, verdict); + } + } + } + if (!session.breakpoints) session.breakpoints = new Map(); session.breakpoints.set(bpId, newBreakpoint); this.ctx.logger.info( diff --git a/src/session/breakpoints/logpoint-checks.ts b/src/session/breakpoints/logpoint-checks.ts new file mode 100644 index 000000000..a29321a38 --- /dev/null +++ b/src/session/breakpoints/logpoint-checks.ts @@ -0,0 +1,134 @@ +/** + * A run's check of its logpoint messages, on the stored records (issues + * #1334, #1349). The verdict comes from the policy (`validateLogMessage` with + * the run's checker); the record keeps the caller's `logMessage` and gains the + * verdict and, for a checked repair only, the wire. Language-free: nothing + * here reads a message. + */ +import type { AdapterPolicy, Breakpoint, LogMessageChecker, LogMessageVerdict } from '@debugmcp/shared'; + +/** A record's check as the answers list it. */ +export interface LogpointCheckNote { + breakpointId: string; + file: string; + line: number; + logMessage: string; + /** What the adapter received, when it is not `logMessage`. */ + logMessageSent?: string; + status: Exclude; + /** The policy's sentence: what was found, and on whose authority. */ + logMessageCheck: string; +} + +/** Forget a previous run's check: no verdict, no wire (a launch, a restart, an attach, a child without its own check). */ +export function clearLogMessageCheck(bp: Pick): void { + delete bp.wireLogMessage; + delete bp.logMessageVerdict; +} + +/** Store a verdict on a record: the wire only for a checked repair; nothing for `refused` or no verdict. */ +export function applyLogMessageVerdict(bp: Breakpoint, verdict: LogMessageVerdict | undefined): void { + clearLogMessageCheck(bp); + if (verdict === undefined || verdict.status === 'refused') { + return; + } + bp.logMessageVerdict = verdict; + if (verdict.status === 'rewritten' && verdict.wire !== bp.logMessage) { + bp.wireLogMessage = verdict.wire; + } +} + +/** + * The policy's verdict on one message, never throwing: a policy that throws + * or rejects gives `unchecked` with the cause, which sends the message as + * written — a failure of the check is never a verdict on the message. + */ +export async function verdictFor( + policy: Pick | undefined, + logMessage: string, + condition: string | undefined, + checker: LogMessageChecker | undefined +): Promise { + if (!policy?.validateLogMessage) { + return undefined; + } + try { + return await policy.validateLogMessage(logMessage, condition, checker); + } catch (error) { + const reason = error instanceof Error ? error.message : String(error); + return { status: 'unchecked', note: `Not checked (the check failed: ${reason}); sent as written.` }; + } +} + +/** + * Check every logpoint among `records` through `checker`, concurrently, and + * store what came back — unless the run ended meanwhile (`isCurrent`), or the + * record left the store (`isStored`): a verdict never outlives its run. + */ +export async function checkLogpoints( + policy: Pick | undefined, + records: Breakpoint[], + checker: LogMessageChecker | undefined, + isCurrent: () => boolean, + isStored: (bp: Breakpoint) => boolean +): Promise { + if (!policy?.validateLogMessage) { + return; + } + const logpoints = records.filter((bp): bp is Breakpoint & { logMessage: string } => bp.logMessage !== undefined); + const verdicts = await Promise.all(logpoints.map((bp) => verdictFor(policy, bp.logMessage, bp.condition, checker))); + if (!isCurrent()) { + return; + } + logpoints.forEach((bp, index) => { + if (isStored(bp)) { + applyLogMessageVerdict(bp, verdicts[index]); + } + }); +} + +/** The records whose check has something to say, for a launch, restart or attach answer. */ +export function logpointCheckNotes(records: Iterable): LogpointCheckNote[] { + const notes: LogpointCheckNote[] = []; + for (const bp of records) { + const verdict = bp.logMessageVerdict; + if (bp.logMessage === undefined || verdict === undefined || verdict.status === 'refused' || verdict.note === undefined) { + continue; + } + notes.push({ + breakpointId: bp.id, + file: bp.file, + line: bp.line, + logMessage: bp.logMessage, + ...(bp.wireLogMessage !== undefined && bp.wireLogMessage !== bp.logMessage ? { logMessageSent: bp.wireLogMessage } : {}), + status: verdict.status, + logMessageCheck: verdict.note + }); + } + return notes; +} + +/** The answer field: present only when some logpoint's check has something to say. */ +export function logpointChecksField(records: Iterable): { logMessageChecks?: LogpointCheckNote[] } { + const notes = logpointCheckNotes(records); + return notes.length > 0 ? { logMessageChecks: notes } : {}; +} + +/** + * A stored breakpoint as an answer shows it (issues #1334, #1349): the + * caller's `logMessage`, `logMessageSent` when the adapter received something + * else, and the check's sentence when it has one. The record's own bookkeeping + * (`wireLogMessage`, `logMessageVerdict`) is not part of the answer. + */ +export function publicBreakpoint(bp: Breakpoint): Omit & { + logMessageSent?: string; + logMessageCheck?: string; +} { + const { wireLogMessage, logMessageVerdict, ...rest } = bp; + const note = logMessageVerdict !== undefined && logMessageVerdict.status !== 'refused' ? logMessageVerdict.note : undefined; + return { + ...rest, + ...(wireLogMessage !== undefined && wireLogMessage !== bp.logMessage ? { logMessageSent: wireLogMessage } : {}), + ...(note !== undefined ? { logMessageCheck: note } : {}) + }; +} diff --git a/src/session/launch/debug-launcher.ts b/src/session/launch/debug-launcher.ts index 1a5437c73..5462a5a85 100644 --- a/src/session/launch/debug-launcher.ts +++ b/src/session/launch/debug-launcher.ts @@ -38,6 +38,7 @@ import { describeReleasedChildren, describeTreeAnswer, selectSettledInTree, with import { composeStopSnapshot } from '../inspection/stop-snapshot.js'; import type { BreakpointController, ResyncOutcome } from '../breakpoints/breakpoint-controller.js'; import { reresolveAnchors, type AnchorResolution } from '../breakpoints/anchor-resolution.js'; +import { logpointChecksField } from '../breakpoints/logpoint-checks.js'; import { buildLogpointDowngradeLaunchWarning, buildNoDebugFailureNote, @@ -914,6 +915,8 @@ export class DebugLauncher { ...describeTreeAnswer(finalSession, this.ctx.descendantsOf(sessionId)), ...(pausedChild ? { pausedChild } : {}), ...(childrenClosed > 0 ? { childrenClosed } : {}), + // What this run's logpoint check found, when it found something to say (issue #1334). + ...logpointChecksField(finalSession.breakpoints.values()), }, }; } catch (error) { diff --git a/src/session/launch/proxy-launcher.ts b/src/session/launch/proxy-launcher.ts index dd2c1557c..20fb96e65 100644 --- a/src/session/launch/proxy-launcher.ts +++ b/src/session/launch/proxy-launcher.ts @@ -29,9 +29,12 @@ import { type LanguageSpecificLaunchConfig, launchTargetKeysOf, namesLaunchTarget, - redactSecretsInString + redactSecretsInString, + toInitialBreakpoint } from '@debugmcp/shared'; import { TEST_RUNNER_KEY } from './test-runner-gate.js'; +import { describeAdapterRuntime } from './spawn-command.js'; +import { checkLogpoints, clearLogMessageCheck } from '../breakpoints/logpoint-checks.js'; import { AdapterLease } from '../../adapters/adapter-lease.js'; import { DebugSessionCreationError, PythonNotFoundError } from '../../errors/debug-errors.js'; import { ProxyConfig, launchConfigIsAttach } from '../../proxy/proxy-config.js'; @@ -45,6 +48,11 @@ import { detectChildDebuggingOptOut } from '../run-facts.js'; import { callerLaunchInputs, collectLaunchConfigNotices, type CallerLaunchInput, collectAttachTransformNotices } from './launch-config-diagnostics.js'; +/** Why an attach's logpoints are not checked (issue #1334): the policy words the rest. */ +const ATTACH_NOT_CHECKED = 'the program runs in a process this server did not start'; +/** Why a launch that connects to its adapter is not checked: there is no runtime of this server's to ask. */ +const CONNECTED_LAUNCH_NOT_CHECKED = "this launch's adapter is not a process this server started"; + /** * Everything `start()` needs about the launch, as one object. * @@ -165,6 +173,12 @@ export class ProxyLauncher { session.run.breakpointStopOccurred = undefined; session.run.inFlightChildReleases = undefined; session.run.deliveredStepFilterHints = undefined; + // A logpoint check belongs to one run (issue #1334): no previous run's + // wire is sent before this run's own check, and its checkers stop. + for (const bp of session.breakpoints.values()) { + clearLogMessageCheck(bp); + } + void this.ctx.logMessageCheckers.endRun(session.id); // Log entrance for Windows CI debugging this.ctx.logger.info( @@ -202,6 +216,10 @@ export class ProxyLauncher { // and the store throws once a close has removed the session. const { lease, plan } = outcome; try { + // The run's logpoint check, once the launch has fixed the interpreter + // and before anything reaches the adapter (issue #1334). Ahead of the + // commit, whose store write throws when a close landed meanwhile. + await this.checkRunLogpoints(session, inputs, plan); this.commitPreparation(session, outcome.record); // Create and start ProxyManager with the adapter. Ownership moves here: @@ -231,6 +249,11 @@ export class ProxyLauncher { }; this.ctx.setupProxyEventHandlers(session, proxyManager, effectiveLaunchArgs); + // The worker's initial set, read from the store after the check with no + // await in between: each logpoint goes as this run's check left it + // (issue #1334). A breakpoint set meanwhile is in it too. + plan.proxyConfig.initialBreakpoints = Array.from(session.breakpoints.values()).map(toInitialBreakpoint); + // Start the proxy await proxyManager.start(plan.proxyConfig); @@ -240,6 +263,43 @@ export class ProxyLauncher { } } + /** + * Bind the run's logpoint checker and check every stored logpoint through + * the policy (issues #1334, #1349). A launch's messages are evaluated by the + * adapter's own runtime — the executable, environment and working directory + * the worker will spawn it with — and the transformed configuration the + * adapter receives says whether the program runs on that runtime. An attach + * debugs a process this server did not start: there is nothing to ask, and + * the policy says so. No check starts a process unless a policy asks. + */ + private async checkRunLogpoints( + session: ManagedSession, + inputs: LaunchInputs, + plan: AdapterLaunchPlan + ): Promise { + const policy = this.ctx.selectPolicy(session.language); + const runtime = inputs.isAttachMode ? undefined : describeAdapterRuntime(policy, plan.proxyConfig); + const checkers = this.ctx.logMessageCheckers; + const generation = checkers.beginRun( + session.id, + runtime + ? { runtime, launchConfig: plan.launchConfig as Record } + : { noRuntimeCause: inputs.isAttachMode ? ATTACH_NOT_CHECKED : CONNECTED_LAUNCH_NOT_CHECKED } + ); + const records = Array.from(session.breakpoints.values()); + // No run: the session closed while the launch was being prepared (the commit below then fails). + if (generation === undefined || !records.some((bp) => bp.logMessage !== undefined)) { + return; + } + await checkLogpoints( + policy, + records, + checkers.checkerFor(session.id), + () => checkers.currentGeneration(session.id) === generation, + (bp) => session.breakpoints.get(bp.id) === bp + ); + } + /** * Everything the launch needs before an adapter exists: this run's log * directory, a free adapter port, the breakpoint snapshots, and the generic @@ -268,21 +328,14 @@ export class ProxyLauncher { // Get free port for adapter const adapterPort = await this.ctx.findFreePort(); - const initialBreakpoints = Array.from(session.breakpoints.values()).map((bp) => { - // Breakpoint file path has been validated by server.ts before reaching here. - // Carry every per-breakpoint field (condition, logMessage, suspendPolicy) — - // dropping one here silently loses it for the whole launch (#235). - // The store id is echoed back by the worker's breakpoints_synced - // status for exact store matching (issue #439). - return { - id: bp.id, - file: bp.file, // Use the validated path - line: bp.line, - condition: bp.condition, - logMessage: bp.logMessage, - suspendPolicy: bp.suspendPolicy, - }; - }); + // Breakpoint file path has been validated by server.ts before reaching here. + // Every per-breakpoint field (condition, logMessage, suspendPolicy) is + // carried — dropping one here silently loses it for the whole launch + // (#235) — and the store id, which the worker's breakpoints_synced status + // echoes for exact store matching (issue #439). A real launch reads the + // set again after its logpoint check (`start`, issue #1334); this one is + // the dry run's. + const initialBreakpoints = Array.from(session.breakpoints.values()).map(toInitialBreakpoint); const initialFunctionBreakpoints = Array.from(session.functionBreakpoints?.values() ?? []).map((bp) => ({ name: bp.functionName, diff --git a/src/session/launch/spawn-command.ts b/src/session/launch/spawn-command.ts index 20a3eefe3..16ed30fe5 100644 --- a/src/session/launch/spawn-command.ts +++ b/src/session/launch/spawn-command.ts @@ -6,8 +6,12 @@ * rendered as `command args…` or `[connect] host:port` — so the answer reads * the same as it always did. */ +import { existsSync } from 'fs'; import { launchTargetKeysOf, type AdapterPolicy, type AdapterSpawnPayload } from '@debugmcp/shared'; import type { ProxyConfig } from '../../proxy/proxy-config.js'; +import { adapterSpawnCwd } from '../../proxy/adapter-cwd.js'; +import { proxyWorkerCwd } from '../../implementations/process-launcher-impl.js'; +import type { CheckerRuntime } from '../log-message-checkers.js'; /** A code-string target longer than this is cut in the dry run's `script`. */ const TARGET_PREVIEW_LENGTH = 60; @@ -53,11 +57,8 @@ export type SpawnCommandSource = Pick< * connect to) for this configuration. Throws, naming the policy, when the * policy cannot say — the worker refused the same way. */ -export function describeSpawnCommand( - policy: Pick, - config: SpawnCommandSource -): string { - const payload: AdapterSpawnPayload = { +function spawnPayloadOf(config: SpawnCommandSource): AdapterSpawnPayload { + return { executablePath: config.executablePath ?? '', adapterHost: config.adapterHost, adapterPort: config.adapterPort, @@ -66,7 +67,41 @@ export function describeSpawnCommand( launchConfig: config.launchConfig, adapterCommand: config.adapterCommand }; - const spawn = policy.getAdapterSpawnConfig?.(payload); +} + +/** + * Where the worker will run the adapter: its executable, environment and + * working directory, read from the policy's spawn config the way the worker + * reads it (and the cwd decided by the worker's own rule). The logpoint + * checker runs there, so it imports what the adapter imports (issue #1334). + * Undefined when the policy connects to an adapter instead of spawning one, + * or cannot say. + */ +export function describeAdapterRuntime( + policy: Pick, + config: SpawnCommandSource +): CheckerRuntime | undefined { + let spawn: ReturnType> | undefined; + try { + spawn = policy.getAdapterSpawnConfig?.(spawnPayloadOf(config)); + } catch { + return undefined; + } + if (!spawn || spawn.mode !== 'spawn' || spawn.command.length === 0) { + return undefined; + } + return { + command: spawn.command, + ...(spawn.env ? { env: spawn.env } : {}), + cwd: adapterSpawnCwd(spawn.cwd, process.env, existsSync) ?? proxyWorkerCwd() + }; +} + +export function describeSpawnCommand( + policy: Pick, + config: SpawnCommandSource +): string { + const spawn = policy.getAdapterSpawnConfig?.(spawnPayloadOf(config)); if (!spawn) { throw new Error(`Cannot determine adapter command for dry run (policy: ${policy.name})`); } diff --git a/src/session/log-message-checkers.ts b/src/session/log-message-checkers.ts new file mode 100644 index 000000000..00b31b0ba --- /dev/null +++ b/src/session/log-message-checkers.ts @@ -0,0 +1,546 @@ +/** + * The processes that check logpoint messages on a run's own runtime (issues + * #1334, #1349). + * + * A policy describes its checker (`LogMessageCheckerSpec`: the arguments that + * follow the run's adapter executable) and asks it questions through the + * `LogMessageChecker` handle the core passes to `validateLogMessage`. This + * service owns the processes: it knows nothing of the language, the questions + * or the answers beyond "one JSON object per line". + * + * - One process per run (a root session's launch, restart or attach) and spec + * key, started on the first question and never before (a dry run, a run with + * no logpoint and an attach start none). Concurrent questions share it: the + * first one spawns, the rest queue, one question in flight at a time. + * - Spoken to in ASCII-only JSON, one line each way: non-ASCII characters and + * lone surrogates travel as `\uXXXX` escapes, so no platform code page can + * touch them. + * - Bounded: the first answer within `startMs` (the interpreter's start is in + * it), every later one within `requestMs`, an answer line within + * `maxAnswerBytes` (counted on the raw bytes before any newline is looked + * for or any JSON parsed), a question within `maxRequestBytes`. Every bound + * goes through `bounded()`, the one place that owns a timer. + * - Settled on whichever of the child's `error`, `exit` and `close`, a stream + * `error`, a bound or a stop comes first, once: a spawn that fails emits + * `error` and `close` and no `exit`. Every waiter gets an answer — `ok: + * false` with the cause when the process cannot give one. + * - A process that never answered (it could not start, or took longer than + * `startMs`) leaves its run unchecked from then on. One that answered and + * then failed (a crash, a bound) is replaced once per run; after that, the + * run is unchecked. + * - Torn down when the run ends (the root session's state goes terminal, or it + * is removed), when the session closes (awaited), when the next run of the + * session begins, and at server exit (awaited): its stdin is closed — the + * checker exits when its input closes, which is also what happens when this + * server is killed outright — and it is killed if it has not exited within + * `stopGraceMs`. + * - Every callback is tied to the process object it came from, and every + * question to the run generation it was asked in: an old process's late + * events reach only itself, and a handle from an ended run answers that the + * run ended. + * + * Not here yet: an idle reap of a run's checker, and a startup reaper for a + * checker whose server died while it was wedged in a request (the checker + * reads EOF and exits by itself once its request returns). + */ +import { spawn as nodeSpawn, type ChildProcess } from 'node:child_process'; +import type { ILogger, LogMessageChecker, LogMessageCheckerReply, LogMessageCheckerSpec } from '@debugmcp/shared'; + +/** Where a run's checkers run: the executable, environment and working directory of its adapter. */ +export interface CheckerRuntime { + command: string; + env?: NodeJS.ProcessEnv; + cwd?: string; +} + +/** What a run says about where its logpoint messages are evaluated. */ +export interface CheckerRunBinding { + /** The runtime this server started for the run; absent when it started none (an attach). */ + runtime?: CheckerRuntime; + /** Why no runtime can be asked, when `runtime` is absent. */ + noRuntimeCause?: string; + /** The launch configuration the adapter receives (launch only), handed to the policy. */ + launchConfig?: Readonly>; +} + +export interface LogMessageCheckerBounds { + /** The first answer of a process, its start included. */ + startMs: number; + /** Every later answer. */ + requestMs: number; + /** One answer line, in bytes, before a newline is looked for. */ + maxAnswerBytes: number; + /** One question line, in bytes. */ + maxRequestBytes: number; + /** After stdin closes, how long a stopping process has before it is killed (and then to exit). */ + stopGraceMs: number; + /** Replacements of a process that answered and then failed, per run and spec. */ + restartsPerRun: number; +} + +export const DEFAULT_CHECKER_BOUNDS: Readonly = Object.freeze({ + startMs: 5000, + requestMs: 2000, + maxAnswerBytes: 64 * 1024, + maxRequestBytes: 64 * 1024, + stopGraceMs: 1000, + restartsPerRun: 1 +}); + +/** Starts a checker process (injectable for tests; the default is node's spawn with piped stdio, hidden). */ +export type CheckerSpawn = ( + command: string, + args: readonly string[], + options: { cwd?: string; env?: NodeJS.ProcessEnv } +) => ChildProcess; + +const defaultSpawn: CheckerSpawn = (command, args, options) => + nodeSpawn(command, [...args], { + cwd: options.cwd, + env: options.env, + stdio: ['pipe', 'pipe', 'pipe'], + windowsHide: true + }); + +export interface LogMessageCheckersOptions { + logger: ILogger; + /** Subscribe to a root session's state changes and its removal; returns the unsubscribe. */ + watch: (sessionId: string, listener: () => void) => () => void; + /** Whether the session's run is over: its state is terminal, or it is gone. */ + runEnded: (sessionId: string) => boolean; + spawn?: CheckerSpawn; + bounds?: Partial; +} + +/** + * The one place a checker's timer lives (each question, a stop's grace): the + * work's outcome, or `onExpiry()`'s when `ms` pass first. The timer is cleared + * on every path. A shared deadline primitive would replace this function only. + */ +export function bounded(ms: number, work: Promise, onExpiry: () => T): Promise { + let timer: NodeJS.Timeout | undefined; + const expiry = new Promise((resolve) => { + timer = setTimeout(() => resolve(onExpiry()), ms); + timer.unref?.(); + }); + return Promise.race([work, expiry]).finally(() => clearTimeout(timer)); +} + +/** JSON with every non-ASCII code unit escaped: what reaches the pipe is ASCII on every platform. */ +export function asciiJson(value: unknown): string { + return JSON.stringify(value).replace(/[\u007f-\uffff]/g, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, '0')}`); +} + +const STDERR_TAIL_BYTES = 2048; + +/** One checker process and its questions. Its listeners touch nothing but this object. */ +class CheckerProcess { + private child: ChildProcess | undefined; + /** Why it can answer nothing more; set once. */ + private gone: string | undefined; + /** It answered at least once: it started. */ + private answeredOnce = false; + private pending: ((reply: LogMessageCheckerReply) => void) | undefined; + private chunks: Buffer[] = []; + private bufferedBytes = 0; + private stderrTail = ''; + private turn: Promise = Promise.resolve(); + private readonly exited: Promise; + private markExited!: () => void; + private stopping: Promise | undefined; + + constructor( + private readonly label: string, + private readonly bounds: LogMessageCheckerBounds, + private readonly logger: ILogger + ) { + this.exited = new Promise((resolve) => { + this.markExited = resolve; + }); + } + + get pid(): number | undefined { + return this.child?.pid; + } + + /** Why it is no longer usable, if it is not. */ + get failure(): string | undefined { + return this.gone; + } + + get started(): boolean { + return this.answeredOnce; + } + + start(spawn: CheckerSpawn, runtime: CheckerRuntime, spec: LogMessageCheckerSpec): void { + let child: ChildProcess; + try { + child = spawn(runtime.command, spec.args, { cwd: runtime.cwd, env: runtime.env }); + } catch (error) { + this.fail(`the checker could not be started: ${error instanceof Error ? error.message : String(error)}`, false); + this.markExited(); + return; + } + this.child = child; + child.on('error', (error) => { + this.fail(`the checker could not be started or stopped: ${error.message}`, false); + // A spawn that failed has no process: nothing will exit. + if (child.pid === undefined) { + this.markExited(); + } + }); + child.on('exit', (code, signal) => { + this.fail(this.describeExit(code, signal), false); + this.markExited(); + }); + child.on('close', (code, signal) => { + this.fail(this.describeExit(code, signal), false); + this.markExited(); + }); + // EPIPE on a write to a dead process, or a read error, must not escape. + child.stdin?.on('error', (error) => this.fail(`the checker's input failed: ${error.message}`, true)); + child.stdout?.on('error', (error) => this.fail(`the checker's output failed: ${error.message}`, true)); + child.stderr?.on('error', () => {}); + child.stdout?.on('data', (chunk: Buffer) => this.onOutput(chunk)); + child.stderr?.on('data', (chunk: Buffer) => { + this.stderrTail = (this.stderrTail + chunk.toString('utf8')).slice(-STDERR_TAIL_BYTES); + }); + this.logger.info(`[LogMessageCheckers] Started checker ${this.label} (pid ${child.pid ?? 'none'})`); + } + + /** Ask one question; questions run one at a time, in order. Never rejects. */ + ask(line: string): Promise { + const reply = this.turn.then(() => this.send(line)); + this.turn = reply; + return reply; + } + + private send(line: string): Promise { + if (this.gone !== undefined || !this.child?.stdin) { + return Promise.resolve({ ok: false, cause: this.gone ?? 'the checker has no input' }); + } + const first = !this.answeredOnce; + const ms = first ? this.bounds.startMs : this.bounds.requestMs; + const answer = new Promise((resolve) => { + this.pending = resolve; + }); + try { + this.child.stdin.write(`${line}\n`); + } catch (error) { + this.fail(`the checker's input failed: ${error instanceof Error ? error.message : String(error)}`, true); + } + return bounded(ms, answer, () => { + const cause = first + ? `the checker did not start and answer within ${ms} ms` + : `the checker did not answer within ${ms} ms`; + this.fail(cause, true); + return { ok: false, cause }; + }); + } + + private onOutput(chunk: Buffer): void { + if (this.gone !== undefined) { + return; + } + // The bound is on raw bytes, before any newline is looked for. + let start = 0; + let newline = chunk.indexOf(0x0a); + while (newline !== -1) { + if (this.bufferedBytes + (newline - start) > this.bounds.maxAnswerBytes) { + this.fail(`the checker's answer was longer than ${this.bounds.maxAnswerBytes} bytes`, true); + return; + } + this.chunks.push(chunk.subarray(start, newline)); + const line = Buffer.concat(this.chunks).toString('utf8').replace(/\r$/, ''); + this.chunks = []; + this.bufferedBytes = 0; + this.onLine(line); + if (this.gone !== undefined) { + return; + } + start = newline + 1; + newline = chunk.indexOf(0x0a, start); + } + const rest = chunk.length - start; + if (this.bufferedBytes + rest > this.bounds.maxAnswerBytes) { + this.fail(`the checker's answer was longer than ${this.bounds.maxAnswerBytes} bytes`, true); + return; + } + if (rest > 0) { + this.chunks.push(chunk.subarray(start)); + this.bufferedBytes += rest; + } + } + + private onLine(line: string): void { + const resolve = this.pending; + if (!resolve) { + this.fail('the checker wrote output nobody asked for', true); + return; + } + let value: unknown; + try { + value = JSON.parse(line); + } catch { + this.fail("the checker's answer was not JSON", true); + return; + } + this.pending = undefined; + this.answeredOnce = true; + resolve({ ok: true, value }); + } + + private describeExit(code: number | null, signal: NodeJS.Signals | null): string { + const how = signal ? `signal ${signal}` : `code ${code ?? 'unknown'}`; + const tail = this.stderrTail.trim().split(/\r?\n/).pop()?.slice(0, 300); + return `the checker exited (${how})${tail ? `: ${tail}` : ''}`; + } + + /** It can answer nothing more: settle the question in flight and, when asked, kill it. Idempotent. */ + private fail(cause: string, kill: boolean): void { + if (this.gone === undefined) { + this.gone = cause; + this.logger.warn(`[LogMessageCheckers] Checker ${this.label}: ${cause}`); + } + const resolve = this.pending; + this.pending = undefined; + resolve?.({ ok: false, cause: this.gone }); + if (kill) { + this.kill(); + } + } + + private kill(): void { + const child = this.child; + if (!child || child.exitCode !== null || child.signalCode !== null) { + return; + } + try { + child.kill('SIGKILL'); + } catch { + // The 'error' listener reports a failed kill. + } + } + + /** + * Close its input, give it `stopGraceMs` to exit, then kill it and give it + * as long again. Idempotent; resolves when it exited or the waits ran out. + */ + stop(cause: string): Promise { + if (this.stopping) { + return this.stopping; + } + this.fail(cause, false); + const child = this.child; + this.stopping = (async () => { + if (!child) { + return; + } + try { + child.stdin?.end(); + } catch { + // Already closed. + } + const grace = this.bounds.stopGraceMs; + const exitedInTime = await bounded(grace, this.exited.then(() => true), () => false); + if (exitedInTime) { + return; + } + this.kill(); + const killed = await bounded(grace, this.exited.then(() => true), () => false); + if (!killed) { + this.logger.error(`[LogMessageCheckers] Checker ${this.label} (pid ${child.pid ?? 'none'}) did not exit after it was killed`); + } + })(); + return this.stopping; + } +} + +interface RunState { + generation: number; + binding: CheckerRunBinding; + processes: Map; + /** Per spec key: why the run is unchecked from now on. */ + failedForRun: Map; + restarts: Map; + ended: boolean; +} + +export class LogMessageCheckers { + private readonly runs = new Map(); + private readonly watches = new Map void>(); + private readonly stops = new Set>(); + private readonly bounds: LogMessageCheckerBounds; + private readonly spawn: CheckerSpawn; + private generations = 0; + + constructor(private readonly options: LogMessageCheckersOptions) { + this.bounds = { ...DEFAULT_CHECKER_BOUNDS, ...(options.bounds ?? {}) }; + this.spawn = options.spawn ?? defaultSpawn; + } + + /** + * A new run of a root session begins (a launch, a restart, an attach): the + * previous run's checkers are stopped, and questions asked from now on are + * this run's. Returns the run's generation — or undefined, with no run, + * when the session is already gone or its state terminal: a close that + * landed while the launch was being prepared has already closed its + * checkers, and a run begun after it would have nothing left to end it. + */ + beginRun(rootSessionId: string, binding: CheckerRunBinding): number | undefined { + this.endRun(rootSessionId); + if (this.options.runEnded(rootSessionId)) { + this.runs.delete(rootSessionId); + return undefined; + } + const generation = ++this.generations; + this.runs.set(rootSessionId, { + generation, + binding, + processes: new Map(), + failedForRun: new Map(), + restarts: new Map(), + ended: false + }); + if (!this.watches.has(rootSessionId)) { + const unsubscribe = this.options.watch(rootSessionId, () => { + if (this.options.runEnded(rootSessionId)) { + this.endRun(rootSessionId); + } + }); + this.watches.set(rootSessionId, unsubscribe); + } + return generation; + } + + /** The handle `validateLogMessage` asks through, for the session's current run; undefined with no run. */ + checkerFor( + rootSessionId: string, + child?: { targetId: string; configuration: Readonly> } + ): LogMessageChecker | undefined { + const run = this.runs.get(rootSessionId); + if (!run || run.ended) { + return undefined; + } + const generation = run.generation; + return { + ...(run.binding.launchConfig ? { launchConfig: run.binding.launchConfig } : {}), + ...(child ? { child } : {}), + ask: (spec, request) => this.ask(rootSessionId, generation, spec, request) + }; + } + + /** The current run's generation for a root session, while it lasts. */ + currentGeneration(rootSessionId: string): number | undefined { + const run = this.runs.get(rootSessionId); + return run && !run.ended ? run.generation : undefined; + } + + /** The pids of the session's live checker processes (diagnostics and tests). */ + checkerPids(rootSessionId: string): number[] { + const run = this.runs.get(rootSessionId); + return run + ? [...run.processes.values()].filter((p) => p.failure === undefined).map((p) => p.pid).filter((pid): pid is number => pid !== undefined) + : []; + } + + private async ask( + rootSessionId: string, + generation: number, + spec: LogMessageCheckerSpec, + request: unknown + ): Promise { + const run = this.runs.get(rootSessionId); + if (!run || run.generation !== generation || run.ended) { + return { ok: false, cause: 'the run this check belonged to has ended' }; + } + const runtime = run.binding.runtime; + if (!runtime) { + return { ok: false, cause: run.binding.noRuntimeCause ?? 'this server started no runtime for the program' }; + } + let line: string; + try { + line = asciiJson(request); + } catch (error) { + return { ok: false, cause: `the question could not be written: ${error instanceof Error ? error.message : String(error)}` }; + } + if (Buffer.byteLength(line, 'utf8') > this.bounds.maxRequestBytes) { + return { ok: false, cause: `the question is longer than ${this.bounds.maxRequestBytes} bytes` }; + } + const process = this.processFor(run, rootSessionId, runtime, spec); + if (typeof process === 'string') { + return { ok: false, cause: process }; + } + return process.ask(line); + } + + /** The run's process for a spec: the live one, a first one, or one replacement; else why there is none. */ + private processFor( + run: RunState, + rootSessionId: string, + runtime: CheckerRuntime, + spec: LogMessageCheckerSpec + ): CheckerProcess | string { + const failed = run.failedForRun.get(spec.key); + if (failed !== undefined) { + return failed; + } + const current = run.processes.get(spec.key); + if (current && current.failure === undefined) { + return current; + } + if (current) { + // It failed. One that never answered could not start: not again this run. + const restarts = run.restarts.get(spec.key) ?? 0; + if (!current.started || restarts >= this.bounds.restartsPerRun) { + const cause = current.started + ? `the checker failed again in this run (${current.failure})` + : current.failure ?? 'the checker could not be started'; + run.failedForRun.set(spec.key, cause); + return cause; + } + run.restarts.set(spec.key, restarts + 1); + this.track(current.stop('replaced')); + } + const label = `${spec.key} for session ${rootSessionId} (run ${run.generation})`; + const process = new CheckerProcess(label, this.bounds, this.options.logger); + run.processes.set(spec.key, process); + process.start(this.spawn, runtime, spec); + return process; + } + + /** The session's run is over: stop its checkers. Idempotent. */ + endRun(rootSessionId: string): Promise { + const run = this.runs.get(rootSessionId); + if (!run) { + return Promise.resolve(); + } + run.ended = true; + const stopping = Promise.all([...run.processes.values()].map((p) => p.stop('the run ended'))).then(() => undefined); + return this.track(stopping); + } + + /** The session closes: its checkers are stopped and awaited, and it is forgotten. */ + async closeSession(rootSessionId: string): Promise { + const stopping = this.endRun(rootSessionId); + this.runs.delete(rootSessionId); + this.watches.get(rootSessionId)?.(); + this.watches.delete(rootSessionId); + await stopping; + } + + /** Server exit: every checker stopped, every stop already under way awaited. */ + async closeAll(): Promise { + await Promise.all([...this.runs.keys()].map((id) => this.closeSession(id))); + await Promise.all([...this.stops]); + } + + private track(stop: Promise): Promise { + this.stops.add(stop); + const forget = (): void => { + this.stops.delete(stop); + }; + stop.then(forget, forget); + return stop; + } +} diff --git a/src/session/operations-context.ts b/src/session/operations-context.ts index 9ad23dbb5..5c2cfaffc 100644 --- a/src/session/operations-context.ts +++ b/src/session/operations-context.ts @@ -21,10 +21,12 @@ import type { IAdapterRegistry, IFileSystem, ILogger, + LogMessageChecker, SessionState, StackFrame } from '@debugmcp/shared'; import type { ManagedSession } from './session-store.js'; +import type { LogMessageCheckers } from './log-message-checkers.js'; import type { StackTraceResult } from './inspection/frame-anchor-resolver.js'; import type { LocalVariablesResult } from './session-manager-data.js'; import type { CloseSessionOutcome, CustomLaunchRequestArguments } from './session-manager-core.js'; @@ -176,6 +178,16 @@ export interface OperationsContext { snapshotEnabled(): boolean; /** Least-privilege mode (issue #237): 'explicit' withholds snapshot locals. */ variableAccessMode(): VariableAccessMode; + /** The processes that check logpoint messages on a run's own runtime (issues #1334, #1349). */ + readonly logMessageCheckers: LogMessageCheckers; + /** + * The checker a logpoint of `session` is checked through now — its root's + * run, with the child's report when `session` is an adopted child — and a + * test that the run is still the one the check was asked in. Undefined + * before any run, between runs and once the run ended: the next launch + * checks the message. + */ + logpointChecker(session: ManagedSession): { checker: LogMessageChecker; isCurrent: () => boolean } | undefined; } /** @@ -195,6 +207,7 @@ export type ProxyLaunchContext = Pick< | 'findFreePort' | 'setupProxyEventHandlers' | 'redactionEnabled' + | 'logMessageCheckers' >; /** @@ -258,10 +271,10 @@ export type AttachContext = Pick< | 'variableAccessMode' >; -/** Breakpoint tooling: the store, the wire, and both policy sources. */ +/** Breakpoint tooling: the store, the wire, both policy sources, and the run's logpoint checker. */ export type BreakpointContext = Pick< OperationsContext, - 'logger' | 'getSession' | 'selectPolicy' | 'selectStorePolicy' | 'clientBehaviorOf' | 'onStateChange' + 'logger' | 'getSession' | 'selectPolicy' | 'selectStorePolicy' | 'clientBehaviorOf' | 'onStateChange' | 'logpointChecker' >; /** diff --git a/src/session/session-manager-core.ts b/src/session/session-manager-core.ts index 1a51e4c11..250d76a44 100644 --- a/src/session/session-manager-core.ts +++ b/src/session/session-manager-core.ts @@ -9,7 +9,8 @@ import { SessionState, SessionLifecycleState, DebugLanguage, DebugSessionInfo, mapLegacyState, isTerminalSessionState, AdapterPolicy, SessionOutputEntry, redactSecretsInString } from '@debugmcp/shared'; -import type { AttachFootprint, Breakpoint, DapClientBehavior, FunctionBreakpoint, ProgramEndExplanation, SessionStopInfo, StackFrame, StopTopFrameLine } from '@debugmcp/shared'; +import type { AttachFootprint, Breakpoint, DapClientBehavior, FunctionBreakpoint, LogMessageChecker, ProgramEndExplanation, SessionStopInfo, StackFrame, StopTopFrameLine } from '@debugmcp/shared'; +import { toInitialBreakpoint } from '@debugmcp/shared'; import { USER_BREAK_REASONS, BREAKPOINT_STOP_REASONS } from '@debugmcp/shared'; import { stopProvesDebuggerOn } from './debugger-off.js'; import { isRedactionEnabled } from '../utils/redaction-mode.js'; @@ -57,6 +58,8 @@ import { quotesAdapterStderrLine } from './launch/proxy-failure-diagnostics.js'; import type { AnchorResolution } from './breakpoints/anchor-resolution.js'; +import { LogMessageCheckers } from './log-message-checkers.js'; +import { checkLogpoints, clearLogMessageCheck, type LogpointCheckNote } from './breakpoints/logpoint-checks.js'; import { applyBoundLocation, applyHitBreakpointIds, @@ -128,6 +131,8 @@ export interface DebugResultData extends ProxyFailureDiagnostics { * asks for no resume or the target was not paused. */ resumedBeforeDetach?: boolean; + /** The logpoints whose check has something to say (issues #1334, #1349): launch, restart and attach answers. */ + logMessageChecks?: LogpointCheckNote[]; } /** @@ -529,6 +534,14 @@ export abstract class SessionManagerCore extends EventEmitter { /** What the idle sweep closed, by session id, oldest first and bounded (issue #1025). */ private readonly idleExpired = new Map(); + /** + * The processes that check logpoint messages on a run's own runtime (issues + * #1334, #1349), keyed by root session. A run's checkers end with the run + * (its root's state goes terminal, or the root is removed), with the + * session's close (awaited below) and with closeAllSessions. + */ + protected readonly logMessageCheckers: LogMessageCheckers; + /** * Constructor with full dependency injection */ @@ -553,6 +566,14 @@ export abstract class SessionManagerCore extends EventEmitter { }; this.fileSystem.ensureDirSync(this.logDirBase); + this.logMessageCheckers = new LogMessageCheckers({ + logger: this.logger, + watch: (sessionId, listener) => this.onSessionStateChange(sessionId, listener), + runEnded: (sessionId) => { + const session = this.sessionStore.get(sessionId); + return !session || isTerminalSessionState(session.state); + } + }); this.logger.info(`[SessionManager] Initialized. Session logs will be stored in: ${this.logDirBase}`); } @@ -1456,6 +1477,9 @@ export abstract class SessionManagerCore extends EventEmitter { session.pendingProxyStop = undefined; } + // The run's logpoint checkers end before the close answers (issue #1334). + await this.logMessageCheckers.closeSession(sessionId); + this._updateSessionState(session, SessionState.STOPPED); // Also update session lifecycle to TERMINATED @@ -1581,6 +1605,8 @@ export abstract class SessionManagerCore extends EventEmitter { } await this.closeSession(session.id); } + // Any logpoint checker still stopping (a run that ended just now) is awaited too (issue #1334). + await this.logMessageCheckers.closeAll(); this.logger.info('All debug sessions closed'); } @@ -1713,6 +1739,24 @@ export abstract class SessionManagerCore extends EventEmitter { return this.descendantsDeepestFirst(rootId).filter((s) => !isTerminalSessionState(s.state)).length; } + /** + * The logpoint checker for `session`'s current run (issue #1334): its + * root's, with the child's report for an adopted child, and whether that + * run still lasts. Undefined when no run of the root is under way. + */ + protected logpointCheckerOf(session: ManagedSession): { checker: LogMessageChecker; isCurrent: () => boolean } | undefined { + const root = this.rootOf(session); + if (session.parentSessionId !== undefined && session.childReport === undefined) { + return undefined; + } + const generation = this.logMessageCheckers.currentGeneration(root.id); + const checker = this.logMessageCheckers.checkerFor(root.id, session.parentSessionId !== undefined ? session.childReport : undefined); + if (generation === undefined || checker === undefined) { + return undefined; + } + return { checker, isCurrent: () => this.logMessageCheckers.currentGeneration(root.id) === generation }; + } + /** * A child the worker reported on `parent`'s connection. Under the per-tree * cap it becomes a session of its own: the parent's language and @@ -1800,12 +1844,15 @@ export abstract class SessionManagerCore extends EventEmitter { // attach), where two of those facts used to be copied at this point // and the rest were left empty. child.run = parent.run; + child.childReport = { targetId: reported.targetId, configuration: reported.configuration }; // The parent's current breakpoint set, re-sent to the child before it // runs (the hold before configurationDone is where they bind); from then - // on each session's set is its own. + // on each session's set is its own. The parent's logpoint check does + // not travel with it: the child's own, below, decides (issue #1334). for (const bp of parent.breakpoints.values()) { const copy = { ...bp }; resetBinding(copy); + clearLogMessageCheck(copy); child.breakpoints.set(copy.id, copy); } for (const bp of parent.functionBreakpoints?.values() ?? []) { @@ -1822,17 +1869,32 @@ export abstract class SessionManagerCore extends EventEmitter { `[SessionManager] Adopting child ${reported.name} (${reported.targetId}) of session ${parent.id} as session ${child.id}` ); + // The child's logpoints, checked for its own process before it runs + // (issue #1334): a check that cannot establish the child's interpreter + // leaves each message as written, and no failure of it fails the adoption. + const adopted = child; + const childLogpoints = [...adopted.breakpoints.values()].filter((bp) => bp.logMessage !== undefined); + let childPolicy: AdapterPolicy | undefined; + try { + childPolicy = childLogpoints.length > 0 ? this.sessionStore.selectPolicy(adopted.language) : undefined; + } catch { + childPolicy = undefined; + } + const checking = childPolicy?.validateLogMessage ? this.logpointCheckerOf(adopted) : undefined; + if (checking) { + await checkLogpoints( + childPolicy, + childLogpoints, + checking.checker, + checking.isCurrent, + (bp) => adopted.breakpoints.get(bp.id) === bp + ).catch(() => undefined); + } + await view.adopt( { reportId: reported.reportId, - breakpoints: Array.from(child.breakpoints.values()).map((bp) => ({ - id: bp.id, - file: bp.file, - line: bp.line, - condition: bp.condition, - logMessage: bp.logMessage, - suspendPolicy: bp.suspendPolicy - })), + breakpoints: Array.from(child.breakpoints.values()).map(toInitialBreakpoint), functionBreakpoints: Array.from(child.functionBreakpoints.values()).map((bp) => ({ name: bp.functionName, condition: bp.condition diff --git a/src/session/session-manager-operations.ts b/src/session/session-manager-operations.ts index 4d169664f..9a5741d87 100644 --- a/src/session/session-manager-operations.ts +++ b/src/session/session-manager-operations.ts @@ -204,7 +204,9 @@ export abstract class SessionManagerOperations extends SessionManagerData { this.extractLocalsFromResolved(sessionId, stackResult, opts), redactionEnabled: () => this.redactionEnabled(), snapshotEnabled: () => this.snapshotEnabled(), - variableAccessMode: () => this.variableAccessMode() + variableAccessMode: () => this.variableAccessMode(), + get logMessageCheckers() { return facade().logMessageCheckers; }, + logpointChecker: (session) => this.logpointCheckerOf(session) }; } diff --git a/src/session/session-store.ts b/src/session/session-store.ts index f5182ab88..774ebabe2 100644 --- a/src/session/session-store.ts +++ b/src/session/session-store.ts @@ -303,6 +303,11 @@ export interface ManagedSession extends DebugSessionInfo { // Function breakpoints (issue #271 phase 3): session-global, name-addressed, // synced via DAP setFunctionBreakpoints (replace-all per request). functionBreakpoints: Map; + /** + * An adopted child's report as the adapter made it (issue #1081): the + * policy's logpoint check reads which process the child is (issue #1334). + */ + childReport?: { targetId: string; configuration: Record }; // New state model fields sessionLifecycle: SessionLifecycleState; executionState?: ExecutionState; diff --git a/tests/adapters/python/integration/logpoint-corpus/corpus.json b/tests/adapters/python/integration/logpoint-corpus/corpus.json new file mode 100644 index 000000000..42123c69f --- /dev/null +++ b/tests/adapters/python/integration/logpoint-corpus/corpus.json @@ -0,0 +1,3759 @@ +{ + "about": "The 99 counterexamples of the logpoint design's reviews: per row the message as written (DEEP3000: 3,000 additions in one group, built by the test), the value environment its hit runs in (env, frame), and per interpreter the verdict of the reviewed rule, the logs of the message as written and as sent in each environment (pydevd's own hit on a real frame), and the lines of the live run (live). Recorded with debugpy 1.8.20 on CPython 3.11.15 and 3.13.12.", + "rows": [ + { + "id": "cx-c1-1", + "src": "Codex Critical 1", + "msg": "%d {1,2}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "1 2" + }, + "B": { + "asWritten": "1 2" + } + }, + "live": { + "asWritten": "1 2" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "1 2" + }, + "B": { + "asWritten": "1 2" + } + }, + "live": { + "asWritten": "1 2" + } + } + } + }, + { + "id": "cx-c1-2", + "src": "Codex Critical 1", + "msg": "%c {65,2}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "A 2" + }, + "B": { + "asWritten": "A 2" + } + }, + "live": { + "asWritten": "A 2" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "A 2" + }, + "B": { + "asWritten": "A 2" + } + }, + "live": { + "asWritten": "A 2" + } + } + } + }, + { + "id": "cx-c1-3", + "src": "Codex Critical 1", + "msg": "%*s {3,4,5}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": " 4 5" + }, + "B": { + "asWritten": " 4 5" + } + }, + "live": { + "asWritten": " 4 5" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": " 4 5" + }, + "B": { + "asWritten": " 4 5" + } + }, + "live": { + "asWritten": " 4 5" + } + } + } + }, + { + "id": "cx-c1-4", + "src": "Codex Critical 1", + "msg": "%f {1.5,2}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "1.500000 2" + }, + "B": { + "asWritten": "1.500000 2" + } + }, + "live": { + "asWritten": "1.500000 2" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "1.500000 2" + }, + "B": { + "asWritten": "1.500000 2" + } + }, + "live": { + "asWritten": "1.500000 2" + } + } + } + }, + { + "id": "cx-c1-5", + "src": "Codex Critical 1", + "msg": "%d {y:=1,2}", + "expect": { + "3.11": { + "status": "runs", + "assigns": [ + "y" + ], + "envs": { + "A": { + "asWritten": "1 2" + }, + "B": { + "asWritten": "1 2" + } + }, + "live": { + "asWritten": "1 2" + } + }, + "3.13": { + "status": "runs", + "assigns": [ + "y" + ], + "envs": { + "A": { + "asWritten": "1 2", + "assignedAsWritten": { + "y": "1" + } + }, + "B": { + "asWritten": "1 2", + "assignedAsWritten": { + "y": "1" + } + } + }, + "live": { + "asWritten": "1 2", + "assignedAsWritten": { + "y": "1" + } + } + } + } + }, + { + "id": "cx-p-1", + "src": "Codex probe", + "msg": "%% {1,2}", + "expect": { + "3.11": { + "status": "fails", + "envs": { + "A": { + "asWritten": "not all arguments converted during string formatting" + }, + "B": { + "asWritten": "not all arguments converted during string formatting" + } + }, + "live": { + "asWritten": "not all arguments converted during string formatting" + } + }, + "3.13": { + "status": "fails", + "envs": { + "A": { + "asWritten": "not all arguments converted during string formatting" + }, + "B": { + "asWritten": "not all arguments converted during string formatting" + } + }, + "live": { + "asWritten": "not all arguments converted during string formatting" + } + } + } + }, + { + "id": "cx-p-2", + "src": "Codex probe", + "msg": "%s {1,2}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "1 2" + }, + "B": { + "asWritten": "1 2" + } + }, + "live": { + "asWritten": "1 2" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "1 2" + }, + "B": { + "asWritten": "1 2" + } + }, + "live": { + "asWritten": "1 2" + } + } + } + }, + { + "id": "cx-p-3", + "src": "Codex probe", + "msg": "% {1,2}", + "expect": { + "3.11": { + "status": "fails", + "envs": { + "A": { + "asWritten": "unsupported format character '%' (0x\u2026) at index 2" + }, + "B": { + "asWritten": "unsupported format character '%' (0x\u2026) at index 2" + } + }, + "live": { + "asWritten": "unsupported format character '%' (0x\u2026) at index 2" + } + }, + "3.13": { + "status": "fails", + "envs": { + "A": { + "asWritten": "unsupported format character '%' (0x\u2026) at index 2" + }, + "B": { + "asWritten": "unsupported format character '%' (0x\u2026) at index 2" + } + }, + "live": { + "asWritten": "unsupported format character '%' (0x\u2026) at index 2" + } + } + } + }, + { + "id": "cx-p-4", + "src": "Codex probe", + "msg": "100% no group", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "100% no group" + }, + "B": { + "asWritten": "100% no group" + } + }, + "live": { + "asWritten": "100% no group" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "100% no group" + }, + "B": { + "asWritten": "100% no group" + } + }, + "live": { + "asWritten": "100% no group" + } + } + } + }, + { + "id": "cx-p-5", + "src": "Codex probe", + "msg": "100% {}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "100% " + }, + "B": { + "asWritten": "100% " + } + }, + "live": { + "asWritten": "100% " + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "100% " + }, + "B": { + "asWritten": "100% " + } + }, + "live": { + "asWritten": "100% " + } + } + } + }, + { + "id": "cx-p-6", + "src": "Codex probe", + "msg": "{x} %%", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "caf\u00e9 %" + }, + "B": { + "asWritten": "None %" + } + }, + "live": { + "asWritten": "caf\u00e9 %" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "caf\u00e9 %" + }, + "B": { + "asWritten": "None %" + } + }, + "live": { + "asWritten": "caf\u00e9 %" + } + } + } + }, + { + "id": "cx-p-7", + "src": "Codex probe", + "msg": "{x} %d", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{x} %%d", + "envs": { + "A": { + "asWritten": "not enough arguments for format string", + "sent": "caf\u00e9 %d" + }, + "B": { + "asWritten": "not enough arguments for format string", + "sent": "None %d" + } + }, + "live": { + "asWritten": "not enough arguments for format string", + "sent": "caf\u00e9 %d" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{x} %%d", + "envs": { + "A": { + "asWritten": "not enough arguments for format string", + "sent": "caf\u00e9 %d" + }, + "B": { + "asWritten": "not enough arguments for format string", + "sent": "None %d" + } + }, + "live": { + "asWritten": "not enough arguments for format string", + "sent": "caf\u00e9 %d" + } + } + } + }, + { + "id": "cx-p-8", + "src": "Codex probe", + "msg": "{{x}}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "{'caf\u00e9'}" + }, + "B": { + "asWritten": "{None}" + } + }, + "live": { + "asWritten": "{'caf\u00e9'}" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "{'caf\u00e9'}" + }, + "B": { + "asWritten": "{None}" + } + }, + "live": { + "asWritten": "{'caf\u00e9'}" + } + } + } + }, + { + "id": "cx-p-9", + "src": "Codex probe", + "msg": "{y:=10}", + "expect": { + "3.11": { + "status": "runs", + "assigns": [ + "y" + ], + "envs": { + "A": { + "asWritten": "10" + }, + "B": { + "asWritten": "10" + } + }, + "live": { + "asWritten": "10" + } + }, + "3.13": { + "status": "runs", + "assigns": [ + "y" + ], + "envs": { + "A": { + "asWritten": "10", + "assignedAsWritten": { + "y": "10" + } + }, + "B": { + "asWritten": "10", + "assignedAsWritten": { + "y": "10" + } + } + }, + "live": { + "asWritten": "10", + "assignedAsWritten": { + "y": "10" + } + } + } + } + }, + { + "id": "cx-p-10", + "src": "Codex probe", + "msg": "{lambda x: x}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": " at 0x\u2026>" + }, + "B": { + "asWritten": " at 0x\u2026>" + } + }, + "live": { + "asWritten": " at 0x\u2026>" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": " at 0x\u2026>" + }, + "B": { + "asWritten": " at 0x\u2026>" + } + }, + "live": { + "asWritten": " at 0x\u2026>" + } + } + } + }, + { + "id": "cx-p-11", + "src": "Codex probe", + "msg": "{1}{2}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "12" + }, + "B": { + "asWritten": "12" + } + }, + "live": { + "asWritten": "12" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "12" + }, + "B": { + "asWritten": "12" + } + }, + "live": { + "asWritten": "12" + } + } + } + }, + { + "id": "cx-p-12", + "src": "Codex probe", + "msg": "{[y for i in items]!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{[y for i in items]!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "name 'y' is not defined" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "[]" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "name 'y' is not defined" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{[y for i in items]!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "[7, 7, 7, 7]" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "[]" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "[7, 7, 7, 7]" + } + } + } + }, + { + "id": "cx-p-13", + "src": "Codex probe", + "msg": "{list(y for i in items)!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{list(y for i in items)!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "name 'y' is not defined" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "[]" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "name 'y' is not defined" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{list(y for i in items)!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "name 'y' is not defined" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "[]" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "name 'y' is not defined" + } + } + } + }, + { + "id": "cx-p-14", + "src": "Codex probe", + "msg": "{(lambda: y)()!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{(lambda: y)()!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "name 'y' is not defined" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "name 'y' is not defined" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "name 'y' is not defined" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{(lambda: y)()!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "name 'y' is not defined" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "name 'y' is not defined" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "name 'y' is not defined" + } + } + } + }, + { + "id": "cx-p-15", + "src": "Codex probe / Minor 7", + "msg": "{x!r}\rTEXT", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r}'}\rTEXT", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\rTEXT" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None\rTEXT" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\rTEXT" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r}'}\rTEXT", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\rTEXT" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None\rTEXT" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\rTEXT" + } + } + } + }, + { + "id": "cx-p-16", + "src": "Codex probe / Minor 7", + "msg": "{x!r}\r\nTEXT", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r}'}\r\nTEXT", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\r\nTEXT" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None\r\nTEXT" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\nTEXT" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r}'}\r\nTEXT", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\r\nTEXT" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None\r\nTEXT" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\nTEXT" + } + } + } + }, + { + "id": "cx-p-17", + "src": "Codex probe", + "msg": "{x!r}\u0000", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r}'}\u0000", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\u0000" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None\u0000" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\u0000" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r}'}\u0000", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\u0000" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None\u0000" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\u0000" + } + } + } + }, + { + "id": "cx-p-18", + "src": "Codex probe", + "msg": "{x!r}\ud800", + "live": false, + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r}'}\ud800", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\ud800" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None\ud800" + } + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r}'}\ud800", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\ud800" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None\ud800" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\ud800" + } + } + } + }, + { + "id": "cx-p-19", + "src": "Codex probe", + "msg": "{x!r}\u00e9\ud83d\ude00", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r}'}\u00e9\ud83d\ude00", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\u00e9\ud83d\ude00" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None\u00e9\ud83d\ude00" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\u00e9\ud83d\ude00" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r}'}\u00e9\ud83d\ude00", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\u00e9\ud83d\ude00" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None\u00e9\ud83d\ude00" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\u00e9\ud83d\ude00" + } + } + } + }, + { + "id": "cx-p-20", + "src": "Codex probe", + "msg": "{x!r}\\", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r}'}\\", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\\" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None\\" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\\" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r}'}\\", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\\" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None\\" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\\" + } + } + } + }, + { + "id": "cx-p-21", + "src": "Codex probe", + "msg": "{x!r}\u0001\u007f", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r}'}\u0001\u007f", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\u0001\u007f" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None\u0001\u007f" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\u0001\u007f" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r}'}\u0001\u007f", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\u0001\u007f" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None\u0001\u007f" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\u0001\u007f" + } + } + } + }, + { + "id": "cx-p-22", + "src": "Codex probe", + "msg": "{x!r}\u2028", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r}'}\u2028", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\u2028" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None\u2028" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\u2028" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r}'}\u2028", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\u2028" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None\u2028" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'\u2028" + } + } + } + }, + { + "id": "cx-p-23", + "src": "Codex probe", + "msg": "{x!r}'''\"\"\"", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r}'}'''\"\"\"", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9''''\"\"\"" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None'''\"\"\"" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9''''\"\"\"" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r}'}'''\"\"\"", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9''''\"\"\"" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None'''\"\"\"" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9''''\"\"\"" + } + } + } + }, + { + "id": "cx-sh-1", + "src": "Codex Important 5 (replaced __import__)", + "msg": "{x!r}", + "env": "shadowImport", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r}'}", + "envs": { + "shadowImport": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'" + } + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r}'}", + "envs": { + "shadowImport": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'" + } + } + } + } + }, + { + "id": "cx-sh-2", + "src": "Codex Important 5 (fake eval, builtins=None)", + "msg": "{x!r}", + "env": "shadowEval", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r}'}", + "envs": { + "shadowEval": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'" + } + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r}'}", + "envs": { + "shadowEval": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'" + } + } + } + } + }, + { + "id": "cx-sh-3", + "src": "Codex Important 5 (__import__ returns fake module)", + "msg": "{x!r}", + "env": "shadowImportModule", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r}'}", + "envs": { + "shadowImportModule": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'" + } + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r}'}", + "envs": { + "shadowImportModule": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'" + } + } + } + } + }, + { + "id": "cx-sh-4", + "src": "Codex probe (global y)", + "msg": "{[y for i in items]!r}", + "env": "globalY", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{[y for i in items]!r}'}", + "envs": { + "globalY": { + "asWritten": "invalid syntax (, line 1)", + "sent": "[99, 99, 99, 99]" + } + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{[y for i in items]!r}'}", + "envs": { + "globalY": { + "asWritten": "invalid syntax (, line 1)", + "sent": "[99, 99, 99, 99]" + } + } + } + } + }, + { + "id": "cx-sc-1", + "src": "Codex scoping", + "msg": "{local} {free}", + "frame": "scopes", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "scopes": { + "asWritten": "function: closure-local closure | class: class-local class-free" + } + } + }, + "3.13": { + "status": "runs", + "envs": { + "scopes": { + "asWritten": "function: closure-local closure | class: class-local class-free" + } + } + } + } + }, + { + "id": "cx-sc-2", + "src": "Codex scoping", + "msg": "{local!r} {free!r}", + "frame": "scopes", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{local!r}'} {f'{free!r}'}", + "envs": { + "scopes": { + "asWritten": "function: invalid syntax (, line 1) | class: invalid syntax (, line 1)", + "sent": "function: 'closure-local' 'closure' | class: 'class-local' 'class-free'" + } + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{local!r}'} {f'{free!r}'}", + "envs": { + "scopes": { + "asWritten": "function: invalid syntax (, line 1) | class: invalid syntax (, line 1)", + "sent": "function: 'closure-local' 'closure' | class: 'class-local' 'class-free'" + } + } + } + } + }, + { + "id": "cx-sc-3", + "src": "Codex scoping", + "msg": "{[free for i in (1,)]}", + "frame": "scopes", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "scopes": { + "asWritten": "function: name 'free' is not defined | class: name 'free' is not defined" + } + } + }, + "3.13": { + "status": "runs", + "envs": { + "scopes": { + "asWritten": "function: ['closure'] | class: ['class-free']" + } + } + } + } + }, + { + "id": "cx-sc-4", + "src": "Codex scoping", + "msg": "{[free for i in (1,)]!r}", + "frame": "scopes", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{[free for i in (1,)]!r}'}", + "envs": { + "scopes": { + "asWritten": "function: invalid syntax (, line 1) | class: invalid syntax (, line 1)", + "sent": "function: name 'free' is not defined | class: name 'free' is not defined" + } + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{[free for i in (1,)]!r}'}", + "envs": { + "scopes": { + "asWritten": "function: invalid syntax (, line 1) | class: invalid syntax (, line 1)", + "sent": "function: ['closure'] | class: ['class-free']" + } + } + } + } + }, + { + "id": "cx-sc-5", + "src": "Codex scoping", + "msg": "{list(free for i in (1,))}", + "frame": "scopes", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "scopes": { + "asWritten": "function: name 'free' is not defined | class: name 'free' is not defined" + } + } + }, + "3.13": { + "status": "runs", + "envs": { + "scopes": { + "asWritten": "function: name 'free' is not defined | class: name 'free' is not defined" + } + } + } + } + }, + { + "id": "cx-sc-6", + "src": "Codex scoping", + "msg": "{list(free for i in (1,))!r}", + "frame": "scopes", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{list(free for i in (1,))!r}'}", + "envs": { + "scopes": { + "asWritten": "function: invalid syntax (, line 1) | class: invalid syntax (, line 1)", + "sent": "function: name 'free' is not defined | class: name 'free' is not defined" + } + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{list(free for i in (1,))!r}'}", + "envs": { + "scopes": { + "asWritten": "function: invalid syntax (, line 1) | class: invalid syntax (, line 1)", + "sent": "function: name 'free' is not defined | class: name 'free' is not defined" + } + } + } + } + }, + { + "id": "cx-sc-7", + "src": "Codex scoping", + "msg": "{(lambda: free)()!r}", + "frame": "scopes", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{(lambda: free)()!r}'}", + "envs": { + "scopes": { + "asWritten": "function: invalid syntax (, line 1) | class: invalid syntax (, line 1)", + "sent": "function: name 'free' is not defined | class: name 'free' is not defined" + } + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{(lambda: free)()!r}'}", + "envs": { + "scopes": { + "asWritten": "function: invalid syntax (, line 1) | class: invalid syntax (, line 1)", + "sent": "function: name 'free' is not defined | class: name 'free' is not defined" + } + } + } + } + }, + { + "id": "gm-1", + "src": "Gemini CE1 / C1", + "msg": "item %d: {i, x}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "item 3: caf\u00e9" + }, + "B": { + "asWritten": "%d format: a real number is required, not str" + } + }, + "live": { + "asWritten": "item 3: caf\u00e9" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "item 3: caf\u00e9" + }, + "B": { + "asWritten": "%d format: a real number is required, not str" + } + }, + "live": { + "asWritten": "item 3: caf\u00e9" + } + } + } + }, + { + "id": "gm-2", + "src": "Gemini CE2", + "msg": "hex=%04x {n, x}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "hex=00ff caf\u00e9" + }, + "B": { + "asWritten": "%x format: an integer is required, not NoneType" + } + }, + "live": { + "asWritten": "hex=00ff caf\u00e9" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "hex=00ff caf\u00e9" + }, + "B": { + "asWritten": "%x format: an integer is required, not NoneType" + } + }, + "live": { + "asWritten": "hex=00ff caf\u00e9" + } + } + } + }, + { + "id": "gm-3", + "src": "Gemini CE3", + "msg": "pct=%.1f {total, x}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "pct=3.5 caf\u00e9" + }, + "B": { + "asWritten": "must be real number, not str" + } + }, + "live": { + "asWritten": "pct=3.5 caf\u00e9" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "pct=3.5 caf\u00e9" + }, + "B": { + "asWritten": "must be real number, not str" + } + }, + "live": { + "asWritten": "pct=3.5 caf\u00e9" + } + } + } + }, + { + "id": "gm-4", + "src": "Gemini CE4", + "msg": "ch=%c {ch, x}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "ch=A caf\u00e9" + }, + "B": { + "asWritten": "ch=A None" + } + }, + "live": { + "asWritten": "ch=A caf\u00e9" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "ch=A caf\u00e9" + }, + "B": { + "asWritten": "ch=A None" + } + }, + "live": { + "asWritten": "ch=A caf\u00e9" + } + } + } + }, + { + "id": "gm-5", + "src": "Gemini CE5", + "msg": "%*s{w, x, ''}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": " caf\u00e9" + }, + "B": { + "asWritten": "* wants int" + } + }, + "live": { + "asWritten": " caf\u00e9" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": " caf\u00e9" + }, + "B": { + "asWritten": "* wants int" + } + }, + "live": { + "asWritten": " caf\u00e9" + } + } + } + }, + { + "id": "gm-6", + "src": "Gemini CE6 (3.13 checker, 3.11 target)", + "msg": "item %d: {i, \"\\n\".join(map(str, items))}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "item 3: 10\n20\n30\n40" + }, + "B": { + "asWritten": "%d format: a real number is required, not str" + } + }, + "live": { + "asWritten": "item 3: 10\n20\n30\n40" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "item 3: 10\n20\n30\n40" + }, + "B": { + "asWritten": "%d format: a real number is required, not str" + } + }, + "live": { + "asWritten": "item 3: 10\n20\n30\n40" + } + } + } + }, + { + "id": "gm-7", + "src": "Gemini CE7 / C2", + "msg": "{entr\u00e9e!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{entr\u00e9e!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'\u00e9'" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{entr\u00e9e!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'\u00e9'" + } + } + } + }, + { + "id": "gm-7b", + "src": "Gemini CE7 / C2", + "msg": "{entr\u00e9e}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "\u00e9" + }, + "B": { + "asWritten": "None" + } + }, + "live": { + "asWritten": "\u00e9" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "\u00e9" + }, + "B": { + "asWritten": "None" + } + }, + "live": { + "asWritten": "\u00e9" + } + } + } + }, + { + "id": "gm-8", + "src": "Gemini CE8 / C2", + "msg": "unclosed {\ud800", + "live": false, + "expect": { + "3.11": { + "status": "fails", + "envs": { + "A": { + "asWritten": "Unbalanced braces in: unclosed {\ud800" + }, + "B": { + "asWritten": "Unbalanced braces in: unclosed {\ud800" + } + } + }, + "3.13": { + "status": "fails", + "envs": { + "A": { + "asWritten": "Unbalanced braces in: unclosed {\ud800" + }, + "B": { + "asWritten": "Unbalanced braces in: unclosed {\ud800" + } + }, + "live": { + "asWritten": "Unbalanced braces in: unclosed {\ud800" + } + } + } + }, + { + "id": "gm-8b", + "src": "Gemini CE8 / C2", + "msg": "unclosed {\ud83c\udf89", + "expect": { + "3.11": { + "status": "fails", + "envs": { + "A": { + "asWritten": "Unbalanced braces in: unclosed {\ud83c\udf89" + }, + "B": { + "asWritten": "Unbalanced braces in: unclosed {\ud83c\udf89" + } + }, + "live": { + "asWritten": "Unbalanced braces in: unclosed {\ud83c\udf89" + } + }, + "3.13": { + "status": "fails", + "envs": { + "A": { + "asWritten": "Unbalanced braces in: unclosed {\ud83c\udf89" + }, + "B": { + "asWritten": "Unbalanced braces in: unclosed {\ud83c\udf89" + } + }, + "live": { + "asWritten": "Unbalanced braces in: unclosed {\ud83c\udf89" + } + } + } + }, + { + "id": "gm-9", + "src": "Gemini CE9 / C2", + "msg": "DEEP3000", + "expect": { + "3.11": { + "status": "unchecked", + "envs": { + "A": { + "asWritten": "maximum recursion depth exceeded during compilation" + }, + "B": { + "asWritten": "maximum recursion depth exceeded during compilation" + } + } + }, + "3.13": { + "status": "unchecked", + "envs": { + "A": { + "asWritten": "maximum recursion depth exceeded during compilation" + }, + "B": { + "asWritten": "maximum recursion depth exceeded during compilation" + } + } + } + } + }, + { + "id": "gm-10", + "src": "Gemini CE10 / C3", + "msg": "%2147483647s {x}", + "hit": false, + "expect": { + "3.11": { + "status": "unchecked", + "envs": { + "A": { + "asWritten": "(not run: the hit would allocate about 2 GB)" + }, + "B": { + "asWritten": "(not run: the hit would allocate about 2 GB)" + } + } + }, + "3.13": { + "status": "unchecked", + "envs": { + "A": { + "asWritten": "(not run: the hit would allocate about 2 GB)" + }, + "B": { + "asWritten": "(not run: the hit would allocate about 2 GB)" + } + } + } + } + }, + { + "id": "gm-10b", + "src": "Gemini CE10, width a hit can afford", + "msg": "%9999s {x}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "%%9999s {x}", + "envs": { + "A": { + "asWritten": "not enough arguments for format string", + "sent": "%9999s caf\u00e9" + }, + "B": { + "asWritten": "not enough arguments for format string", + "sent": "%9999s None" + } + }, + "live": { + "asWritten": "not enough arguments for format string", + "sent": "%9999s caf\u00e9" + } + }, + "3.13": { + "status": "rewritten", + "wire": "%%9999s {x}", + "envs": { + "A": { + "asWritten": "not enough arguments for format string", + "sent": "%9999s caf\u00e9" + }, + "B": { + "asWritten": "not enough arguments for format string", + "sent": "%9999s None" + } + }, + "live": { + "asWritten": "not enough arguments for format string", + "sent": "%9999s caf\u00e9" + } + } + } + }, + { + "id": "gm-11", + "src": "Gemini CE11 / I5", + "msg": "{step:=99}", + "expect": { + "3.11": { + "status": "runs", + "assigns": [ + "step" + ], + "envs": { + "A": { + "asWritten": "99" + }, + "B": { + "asWritten": "99" + } + }, + "live": { + "asWritten": "99" + } + }, + "3.13": { + "status": "runs", + "assigns": [ + "step" + ], + "envs": { + "A": { + "asWritten": "99", + "assignedAsWritten": { + "step": "99" + } + }, + "B": { + "asWritten": "99", + "assignedAsWritten": { + "step": "99" + } + } + }, + "live": { + "asWritten": "99", + "assignedAsWritten": { + "step": "99" + } + } + } + } + }, + { + "id": "gm-11b", + "src": "Gemini I5", + "msg": "{step:=+10}", + "expect": { + "3.11": { + "status": "runs", + "assigns": [ + "step" + ], + "envs": { + "A": { + "asWritten": "10" + }, + "B": { + "asWritten": "10" + } + }, + "live": { + "asWritten": "10" + } + }, + "3.13": { + "status": "runs", + "assigns": [ + "step" + ], + "envs": { + "A": { + "asWritten": "10", + "assignedAsWritten": { + "step": "10" + } + }, + "B": { + "asWritten": "10", + "assignedAsWritten": { + "step": "10" + } + } + }, + "live": { + "asWritten": "10", + "assignedAsWritten": { + "step": "10" + } + } + } + } + }, + { + "id": "gm-11c", + "src": "Gemini I5", + "msg": "{step:=-10}", + "expect": { + "3.11": { + "status": "runs", + "assigns": [ + "step" + ], + "envs": { + "A": { + "asWritten": "-10" + }, + "B": { + "asWritten": "-10" + } + }, + "live": { + "asWritten": "-10" + } + }, + "3.13": { + "status": "runs", + "assigns": [ + "step" + ], + "envs": { + "A": { + "asWritten": "-10", + "assignedAsWritten": { + "step": "-10" + } + }, + "B": { + "asWritten": "-10", + "assignedAsWritten": { + "step": "-10" + } + } + }, + "live": { + "asWritten": "-10", + "assignedAsWritten": { + "step": "-10" + } + } + } + } + }, + { + "id": "gm-11w", + "src": "v2: the named f-string reading of gm-11", + "msg": "{f'{step:=99}'}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": " 0" + }, + "B": { + "asWritten": "'=' alignment not allowed in string format specifier" + } + }, + "live": { + "asWritten": " 0" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": " 0" + }, + "B": { + "asWritten": "'=' alignment not allowed in string format specifier" + } + }, + "live": { + "asWritten": " 0" + } + } + } + }, + { + "id": "gm-11wb", + "src": "v2: the named f-string reading of gm-11b", + "msg": "{f'{step:=+10}'}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "+ 0" + }, + "B": { + "asWritten": "Sign not allowed in string format specifier" + } + }, + "live": { + "asWritten": "+ 0" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "+ 0" + }, + "B": { + "asWritten": "Sign not allowed in string format specifier" + } + }, + "live": { + "asWritten": "+ 0" + } + } + } + }, + { + "id": "gm-11wc", + "src": "v2: the named f-string reading of gm-11c", + "msg": "{f'{step:=-10}'}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": " 0" + }, + "B": { + "asWritten": "Sign not allowed in string format specifier" + } + }, + "live": { + "asWritten": " 0" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": " 0" + }, + "B": { + "asWritten": "Sign not allowed in string format specifier" + } + }, + "live": { + "asWritten": " 0" + } + } + } + }, + { + "id": "gm-12", + "src": "Gemini CE12 / I4", + "msg": "col1\r{x!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "col1\r{f'{x!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "col1\r'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "col1\rNone" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "col1\r'caf\u00e9'" + } + }, + "3.13": { + "status": "rewritten", + "wire": "col1\r{f'{x!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "col1\r'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "col1\rNone" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "col1\r'caf\u00e9'" + } + } + } + }, + { + "id": "gm-12b", + "src": "Gemini I4", + "msg": "col1\r{x}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "col1\rcaf\u00e9" + }, + "B": { + "asWritten": "col1\rNone" + } + }, + "live": { + "asWritten": "col1\rcaf\u00e9" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "col1\rcaf\u00e9" + }, + "B": { + "asWritten": "col1\rNone" + } + }, + "live": { + "asWritten": "col1\rcaf\u00e9" + } + } + } + }, + { + "id": "gm-13", + "src": "Gemini CE13 / I4", + "msg": "a\u0000b {x!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "a\u0000b {f'{x!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "a\u0000b 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "a\u0000b None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "a\u0000b 'caf\u00e9'" + } + }, + "3.13": { + "status": "rewritten", + "wire": "a\u0000b {f'{x!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "a\u0000b 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "a\u0000b None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "a\u0000b 'caf\u00e9'" + } + } + } + }, + { + "id": "gm-13b", + "src": "Gemini I4", + "msg": "a\u0000b {x}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "a\u0000b caf\u00e9" + }, + "B": { + "asWritten": "a\u0000b None" + } + }, + "live": { + "asWritten": "a\u0000b caf\u00e9" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "a\u0000b caf\u00e9" + }, + "B": { + "asWritten": "a\u0000b None" + } + }, + "live": { + "asWritten": "a\u0000b caf\u00e9" + } + } + } + }, + { + "id": "gm-13c", + "src": "Gemini CE13 / I4", + "msg": "a\ud800b {x!r}", + "live": false, + "expect": { + "3.11": { + "status": "rewritten", + "wire": "a\ud800b {f'{x!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "a\ud800b 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "a\ud800b None" + } + } + }, + "3.13": { + "status": "rewritten", + "wire": "a\ud800b {f'{x!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "a\ud800b 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "a\ud800b None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "a\ud800b 'caf\u00e9'" + } + } + } + }, + { + "id": "gm-13d", + "src": "Gemini I4", + "msg": "a\ud800b {x}", + "live": false, + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "a\ud800b caf\u00e9" + }, + "B": { + "asWritten": "a\ud800b None" + } + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "a\ud800b caf\u00e9" + }, + "B": { + "asWritten": "a\ud800b None" + } + }, + "live": { + "asWritten": "a\ud800b caf\u00e9" + } + } + } + }, + { + "id": "gm-14", + "src": "Gemini CE14 / I4", + "msg": "{x!r} '''a''' \"\"\"b\"\"\"", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r}'} '''a''' \"\"\"b\"\"\"", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9' '''a''' \"\"\"b\"\"\"" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None '''a''' \"\"\"b\"\"\"" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9' '''a''' \"\"\"b\"\"\"" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r}'} '''a''' \"\"\"b\"\"\"", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9' '''a''' \"\"\"b\"\"\"" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None '''a''' \"\"\"b\"\"\"" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9' '''a''' \"\"\"b\"\"\"" + } + } + } + }, + { + "id": "gm-15", + "src": "Gemini CE15 / I4", + "msg": "100% {y := 7}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "100%% {y := 7}", + "assigns": [ + "y" + ], + "envs": { + "A": { + "asWritten": "unsupported format character '%' (0x\u2026) at index 5", + "sent": "100% 7" + }, + "B": { + "asWritten": "unsupported format character '%' (0x\u2026) at index 5", + "sent": "100% 7" + } + }, + "live": { + "asWritten": "unsupported format character '%' (0x\u2026) at index 5", + "sent": "100% 7" + } + }, + "3.13": { + "status": "rewritten", + "wire": "100%% {y := 7}", + "assigns": [ + "y" + ], + "envs": { + "A": { + "asWritten": "unsupported format character '%' (0x\u2026) at index 5", + "sent": "100% 7" + }, + "B": { + "asWritten": "unsupported format character '%' (0x\u2026) at index 5", + "assignedAsWritten": { + "y": "7" + }, + "sent": "100% 7", + "assignedSent": { + "y": "7" + } + } + }, + "live": { + "asWritten": "unsupported format character '%' (0x\u2026) at index 5", + "sent": "100% 7" + } + } + } + }, + { + "id": "gm-15b", + "src": "Gemini CE15", + "msg": "99 {y := 7}", + "expect": { + "3.11": { + "status": "runs", + "assigns": [ + "y" + ], + "envs": { + "A": { + "asWritten": "99 7" + }, + "B": { + "asWritten": "99 7" + } + }, + "live": { + "asWritten": "99 7" + } + }, + "3.13": { + "status": "runs", + "assigns": [ + "y" + ], + "envs": { + "A": { + "asWritten": "99 7" + }, + "B": { + "asWritten": "99 7", + "assignedAsWritten": { + "y": "7" + } + } + }, + "live": { + "asWritten": "99 7" + } + } + } + }, + { + "id": "gm-16", + "src": "Gemini CE16 / I4", + "msg": "50%% of {total:.2f}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "50%% of {f'{total:.2f}'}", + "envs": { + "A": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": "50% of 3.50" + }, + "B": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": "Unknown format code 'f' for object of type 'str'" + } + }, + "live": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": "50% of 3.50" + } + }, + "3.13": { + "status": "rewritten", + "wire": "50%% of {f'{total:.2f}'}", + "envs": { + "A": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": "50% of 3.50" + }, + "B": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": "Unknown format code 'f' for object of type 'str'" + } + }, + "live": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": "50% of 3.50" + } + } + } + }, + { + "id": "gm-16b", + "src": "Gemini CE16 / I4", + "msg": "seen={{a}} x={x!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "seen={{a}} x={f'{x!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "seen={1} x='caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "seen={'1'} x=None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "seen={1} x='caf\u00e9'" + } + }, + "3.13": { + "status": "rewritten", + "wire": "seen={{a}} x={f'{x!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "seen={1} x='caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "seen={'1'} x=None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "seen={1} x='caf\u00e9'" + } + } + } + }, + { + "id": "gm-17", + "src": "Gemini CE17 / I6", + "msg": "{t'hi {x}'}", + "expect": { + "3.11": { + "status": "fails", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)" + }, + "B": { + "asWritten": "invalid syntax (, line 1)" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)" + } + }, + "3.13": { + "status": "fails", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)" + }, + "B": { + "asWritten": "invalid syntax (, line 1)" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)" + } + } + } + }, + { + "id": "gm-i4", + "src": "Gemini I4.3 (3.11)", + "msg": "{\"\\n\".join(map(str, items))} {x!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{\"\\n\".join(map(str, items))} {f'{x!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "10\n20\n30\n40 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": " None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "10\n20\n30\n40 'caf\u00e9'" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{\"\\n\".join(map(str, items))} {f'{x!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "10\n20\n30\n40 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": " None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "10\n20\n30\n40 'caf\u00e9'" + } + } + } + }, + { + "id": "mg-1", + "src": "manager: top-level comma", + "msg": "{a, b}", + "expect": { + "3.11": { + "status": "fails", + "envs": { + "A": { + "asWritten": "not all arguments converted during string formatting" + }, + "B": { + "asWritten": "not all arguments converted during string formatting" + } + }, + "live": { + "asWritten": "not all arguments converted during string formatting" + } + }, + "3.13": { + "status": "fails", + "envs": { + "A": { + "asWritten": "not all arguments converted during string formatting" + }, + "B": { + "asWritten": "not all arguments converted during string formatting" + } + }, + "live": { + "asWritten": "not all arguments converted during string formatting" + } + } + } + }, + { + "id": "mg-2", + "src": "manager: top-level comma", + "msg": "{a, b} {x!r}", + "expect": { + "3.11": { + "status": "fails", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)" + }, + "B": { + "asWritten": "invalid syntax (, line 1)" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)" + } + }, + "3.13": { + "status": "fails", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)" + }, + "B": { + "asWritten": "invalid syntax (, line 1)" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)" + } + } + } + }, + { + "id": "mg-3", + "src": "manager: walrus", + "msg": "{y := 7}", + "expect": { + "3.11": { + "status": "runs", + "assigns": [ + "y" + ], + "envs": { + "A": { + "asWritten": "7" + }, + "B": { + "asWritten": "7" + } + }, + "live": { + "asWritten": "7" + } + }, + "3.13": { + "status": "runs", + "assigns": [ + "y" + ], + "envs": { + "A": { + "asWritten": "7" + }, + "B": { + "asWritten": "7", + "assignedAsWritten": { + "y": "7" + } + } + }, + "live": { + "asWritten": "7" + } + } + } + }, + { + "id": "mg-4", + "src": "manager: walrus", + "msg": "{(y := 7)} {x!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{(y := 7)} {f'{x!r}'}", + "assigns": [ + "y" + ], + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "7 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "7 None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "7 'caf\u00e9'" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{(y := 7)} {f'{x!r}'}", + "assigns": [ + "y" + ], + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "7 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "7 None", + "assignedSent": { + "y": "7" + } + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "7 'caf\u00e9'" + } + } + } + }, + { + "id": "mg-5", + "src": "manager: %%", + "msg": "50%% {x}", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "A": { + "asWritten": "50% caf\u00e9" + }, + "B": { + "asWritten": "50% None" + } + }, + "live": { + "asWritten": "50% caf\u00e9" + } + }, + "3.13": { + "status": "runs", + "envs": { + "A": { + "asWritten": "50% caf\u00e9" + }, + "B": { + "asWritten": "50% None" + } + }, + "live": { + "asWritten": "50% caf\u00e9" + } + } + } + }, + { + "id": "mg-6", + "src": "manager: {{", + "msg": "{{x}} {x!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{{x}} {f'{x!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "{'caf\u00e9'} 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "{None} None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "{'caf\u00e9'} 'caf\u00e9'" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{{x}} {f'{x!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "{'caf\u00e9'} 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "{None} None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "{'caf\u00e9'} 'caf\u00e9'" + } + } + } + }, + { + "id": "mg-7", + "src": "manager: CR", + "msg": "a\rb {x!r} c\r\nd", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "a\rb {f'{x!r}'} c\r\nd", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "a\rb 'caf\u00e9' c\r\nd" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "a\rb None c\r\nd" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "a\rb 'caf\u00e9' c\nd" + } + }, + "3.13": { + "status": "rewritten", + "wire": "a\rb {f'{x!r}'} c\r\nd", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "a\rb 'caf\u00e9' c\r\nd" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "a\rb None c\r\nd" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "a\rb 'caf\u00e9' c\nd" + } + } + } + }, + { + "id": "mg-8", + "src": "manager: replaced name (locals repr/format/str)", + "msg": "{x!r} {total:.2f}", + "env": "shadowBuiltinsNames", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r}'} {f'{total:.2f}'}", + "envs": { + "shadowBuiltinsNames": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": "'caf\u00e9' 3.50" + } + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r}'} {f'{total:.2f}'}", + "envs": { + "shadowBuiltinsNames": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": "'caf\u00e9' 3.50" + } + } + } + } + }, + { + "id": "mg-9", + "src": "manager: replaced name (the working form)", + "msg": "{repr(x)} {format(total, '.2f')}", + "env": "shadowBuiltinsNames", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "shadowBuiltinsNames": { + "asWritten": "WRONG WRONG" + } + } + }, + "3.13": { + "status": "runs", + "envs": { + "shadowBuiltinsNames": { + "asWritten": "WRONG WRONG" + } + } + } + } + }, + { + "id": "mg-10", + "src": "manager: replaced name (builtins.repr patched)", + "msg": "{x!r}", + "env": "patchedBuiltinRepr", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r}'}", + "envs": { + "patchedBuiltinRepr": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'" + } + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r}'}", + "envs": { + "patchedBuiltinRepr": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9'" + } + } + } + } + }, + { + "id": "mg-11", + "src": "manager: replaced name (builtins.repr patched)", + "msg": "{repr(x)}", + "env": "patchedBuiltinRepr", + "expect": { + "3.11": { + "status": "runs", + "envs": { + "patchedBuiltinRepr": { + "asWritten": "WRONG" + } + } + }, + "3.13": { + "status": "runs", + "envs": { + "patchedBuiltinRepr": { + "asWritten": "WRONG" + } + } + } + } + }, + { + "id": "v1-1", + "src": "#1334", + "msg": "stale={entry!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "stale={f'{entry!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "stale='old'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "stale=None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "stale='old'" + } + }, + "3.13": { + "status": "rewritten", + "wire": "stale={f'{entry!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "stale='old'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "stale=None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "stale='old'" + } + } + } + }, + { + "id": "v1-2", + "src": "#1334", + "msg": "{total:.2f}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{total:.2f}'}", + "envs": { + "A": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": "3.50" + }, + "B": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": "Unknown format code 'f' for object of type 'str'" + } + }, + "live": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": "3.50" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{total:.2f}'}", + "envs": { + "A": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": "3.50" + }, + "B": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": "Unknown format code 'f' for object of type 'str'" + } + }, + "live": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": "3.50" + } + } + } + }, + { + "id": "v1-3", + "src": "#1334", + "msg": "{x=}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x=}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "x='caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "x=None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "x='caf\u00e9'" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x=}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "x='caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "x=None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "x='caf\u00e9'" + } + } + } + }, + { + "id": "v1-4", + "src": "#1334", + "msg": "{ x = }", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{ x = }'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": " x = 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": " x = None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": " x = 'caf\u00e9'" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{ x = }'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": " x = 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": " x = None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": " x = 'caf\u00e9'" + } + } + } + }, + { + "id": "v1-5", + "src": "#1334", + "msg": "{x!r:>10}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r:>10}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": " 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": " None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": " 'caf\u00e9'" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r:>10}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": " 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": " None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": " 'caf\u00e9'" + } + } + } + }, + { + "id": "v1-6", + "src": "#1349", + "msg": "100% {x}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "100%% {x}", + "envs": { + "A": { + "asWritten": "unsupported format character '%' (0x\u2026) at index 5", + "sent": "100% caf\u00e9" + }, + "B": { + "asWritten": "unsupported format character '%' (0x\u2026) at index 5", + "sent": "100% None" + } + }, + "live": { + "asWritten": "unsupported format character '%' (0x\u2026) at index 5", + "sent": "100% caf\u00e9" + } + }, + "3.13": { + "status": "rewritten", + "wire": "100%% {x}", + "envs": { + "A": { + "asWritten": "unsupported format character '%' (0x\u2026) at index 5", + "sent": "100% caf\u00e9" + }, + "B": { + "asWritten": "unsupported format character '%' (0x\u2026) at index 5", + "sent": "100% None" + } + }, + "live": { + "asWritten": "unsupported format character '%' (0x\u2026) at index 5", + "sent": "100% caf\u00e9" + } + } + } + }, + { + "id": "v1-7", + "src": "v1 table", + "msg": "{d[\"}\"]}", + "expect": { + "3.11": { + "status": "fails", + "envs": { + "A": { + "asWritten": "unterminated string literal (detected at line 1) (, line 1)" + }, + "B": { + "asWritten": "unterminated string literal (detected at line 1) (, line 1)" + } + }, + "live": { + "asWritten": "unterminated string literal (detected at line 1) (, line 1)" + } + }, + "3.13": { + "status": "fails", + "envs": { + "A": { + "asWritten": "unterminated string literal (detected at line 1) (, line 1)" + }, + "B": { + "asWritten": "unterminated string literal (detected at line 1) (, line 1)" + } + }, + "live": { + "asWritten": "unterminated string literal (detected at line 1) (, line 1)" + } + } + } + }, + { + "id": "v1-8", + "src": "v1 table", + "msg": "{'{'}", + "expect": { + "3.11": { + "status": "fails", + "envs": { + "A": { + "asWritten": "Unbalanced braces in: {'{'}" + }, + "B": { + "asWritten": "Unbalanced braces in: {'{'}" + } + }, + "live": { + "asWritten": "Unbalanced braces in: {'{'}" + } + }, + "3.13": { + "status": "fails", + "envs": { + "A": { + "asWritten": "Unbalanced braces in: {'{'}" + }, + "B": { + "asWritten": "Unbalanced braces in: {'{'}" + } + }, + "live": { + "asWritten": "Unbalanced braces in: {'{'}" + } + } + } + }, + { + "id": "v1-9", + "src": "v1 table", + "msg": "{x!z}", + "expect": { + "3.11": { + "status": "fails", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)" + }, + "B": { + "asWritten": "invalid syntax (, line 1)" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)" + } + }, + "3.13": { + "status": "fails", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)" + }, + "B": { + "asWritten": "invalid syntax (, line 1)" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)" + } + } + } + }, + { + "id": "v1-10", + "src": "v1 table", + "msg": "{total:{w}.2f}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{total:{w}.2f}'}", + "envs": { + "A": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": " 3.50" + }, + "B": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": "Unknown format code 'f' for object of type 'str'" + } + }, + "live": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": " 3.50" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{total:{w}.2f}'}", + "envs": { + "A": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": " 3.50" + }, + "B": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": "Unknown format code 'f' for object of type 'str'" + } + }, + "live": { + "asWritten": "invalid decimal literal (, line 1)", + "sent": " 3.50" + } + } + } + }, + { + "id": "d-1", + "src": "design probe", + "msg": "%d {x!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "%%d {f'{x!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "%d 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "%d None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "%d 'caf\u00e9'" + } + }, + "3.13": { + "status": "rewritten", + "wire": "%%d {f'{x!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "%d 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "%d None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "%d 'caf\u00e9'" + } + } + } + }, + { + "id": "d-2", + "src": "design probe", + "msg": "{x!r} %", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r}'} %%", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9' %" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None %" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9' %" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r}'} %%", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9' %" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None %" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9' %" + } + } + } + }, + { + "id": "d-3", + "src": "design probe", + "msg": "order 123456 {x!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "order 123456 {f'{x!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "order 123456 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "order 123456 None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "order 123456 'caf\u00e9'" + } + }, + "3.13": { + "status": "rewritten", + "wire": "order 123456 {f'{x!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "order 123456 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "order 123456 None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "order 123456 'caf\u00e9'" + } + } + } + }, + { + "id": "d-4", + "src": "design probe (independent groups)", + "msg": "{lambda v: v} {x!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{lambda v: v} {f'{x!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": " at 0x\u2026> 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": " at 0x\u2026> None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": " at 0x\u2026> 'caf\u00e9'" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{lambda v: v} {f'{x!r}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": " at 0x\u2026> 'caf\u00e9'" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": " at 0x\u2026> None" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": " at 0x\u2026> 'caf\u00e9'" + } + } + } + }, + { + "id": "d-5", + "src": "design probe (joined groups)", + "msg": "{x, lambda a}{b: a} {x!r}", + "expect": { + "3.11": { + "status": "fails", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)" + }, + "B": { + "asWritten": "invalid syntax (, line 1)" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)" + } + }, + "3.13": { + "status": "fails", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)" + }, + "B": { + "asWritten": "invalid syntax (, line 1)" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)" + } + } + } + }, + { + "id": "d-6", + "src": "design probe", + "msg": "{x!r} {y := 7}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r}'} {y := 7}", + "assigns": [ + "y" + ], + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9' 7" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None 7" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9' 7" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r}'} {y := 7}", + "assigns": [ + "y" + ], + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9' 7" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "None 7", + "assignedSent": { + "y": "7" + } + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'caf\u00e9' 7" + } + } + } + }, + { + "id": "d-7", + "src": "design probe", + "msg": "{d['a:b']!r} {d[\"k\"]:>4}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"{d['a:b']!r}\"} {f'{d[\"k\"]:>4}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'colon-key' 1" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'a:b'" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'colon-key' 1" + } + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{d['a:b']!r}'} {f'{d[\"k\"]:>4}'}", + "envs": { + "A": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'colon-key' 1" + }, + "B": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'a:b'" + } + }, + "live": { + "asWritten": "invalid syntax (, line 1)", + "sent": "'colon-key' 1" + } + } + } + } + ] +} \ No newline at end of file diff --git a/tests/adapters/python/integration/logpoint-corpus/emulate.py b/tests/adapters/python/integration/logpoint-corpus/emulate.py new file mode 100644 index 000000000..3a10f884b --- /dev/null +++ b/tests/adapters/python/integration/logpoint-corpus/emulate.py @@ -0,0 +1,333 @@ +"""The logpoint checker against debugpy's own hit, in this interpreter (issues #1334, #1349). + +Usage: -B -X utf8 emulate.py [--quick] + +The checker source is the one the Python policy ships (the test writes it to a file). It is +loaded as a module, so check() and same_interpreter() are called directly; nothing here is +part of what the server runs. + +A "hit" is pydevd's own PyDB.handle_breakpoint_expression on a real function frame whose +locals are a value environment (A: the fixture's values; B: other types, None, empty), as a +debuggee runs it; the conversion is the installed debugpy's. Reported, for the test to assert: + + corpus every counterexample row (corpus.json): the verdict, and what the message as + written and as sent log in each of its environments, with any local a hit changed + table every row of the 562-row table (table.json): the verdict + generated everyday messages, %-directive x group combinations, starred groups and the fuzz + sets: every message that works as written in A or B, with its verdict when the wire changed + extra three rows the test states inline: a group's own %, a starred group, the length bound + resource the messages that exhaust this process's recursion limit + bounds peak memory (tracemalloc) and time of the worst messages the bounds allow +""" +import builtins +import datetime +import itertools +import json +import os +import re +import sys +import time +import tracemalloc +import warnings +from types import SimpleNamespace + +# This driver's own compiles and hits warn about the fuzz shapes ("'str' object is not +# callable"); the warnings say nothing here, and on stderr they would be megabytes. +warnings.simplefilter("ignore") + +HERE = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, HERE) +import fuzz # noqa: E402 + +source_path, out_path = sys.argv[1], sys.argv[2] +QUICK = "--quick" in sys.argv[3:] +checker = {"__name__": "mcp_logpoint_checker"} +exec(compile(open(source_path, encoding="utf-8").read(), "mcp_logpoint_checker", "exec"), checker) +check = checker["check"] +conv = checker["conv"] +if conv is None: + json.dump({"error": "debugpy is not importable here: " + str(checker["IMPORT_ERROR"])}, open(out_path, "w")) + sys.exit(0) +import debugpy # noqa: E402 +import pydevd # noqa: E402 (importable: the checker put debugpy's vendored pydevd on sys.path) + +ADDR = re.compile(r"0x[0-9A-Fa-f]+") + +ENV_A = {"x": "café", "total": 3.5, "items": [10, 20, 30, 40], "i": 3, "n": 255, "ch": "A", "w": 8, "y": 7, + "step": 0, "a": 1, "b": 2, "entry": "old", "d": {"a:b": "colon-key", "}": "brace", "k": 1}, + "literal": 5, "entrée": "é", "s": "str"} +ENV_B = {"x": None, "total": "3.5", "items": [], "i": "three", "n": None, "ch": 65, "w": "8", "y": "7", + "step": "0", "a": "1", "b": None, "entry": None, "d": {}, "literal": None, "entrée": None, "s": 5} + + +def _recording_import(name, *a, **kw): + return builtins.__import__(name, *a, **kw) + + +class _FakeModule: + @staticmethod + def eval(*a, **kw): + return "WRONG" + + +SPECIAL = { + "shadowImport": dict(ENV_A, __import__=_recording_import), + "shadowEval": dict(ENV_A, eval=lambda *a: "WRONG", builtins=None), + "shadowImportModule": dict(ENV_A, __import__=lambda *a, **k: _FakeModule()), + "shadowBuiltinsNames": dict(ENV_A, repr=lambda *a: "WRONG", format=lambda *a: "WRONG", str=lambda *a: "WRONG"), + "patchedBuiltinRepr": dict(ENV_A), + "globalY": {k: v for k, v in ENV_A.items() if k != "y"}, +} + + +def pydevd_hit(expr, frame): + info = SimpleNamespace(pydev_message=None) + pydevd.PyDB.handle_breakpoint_expression(None, SimpleNamespace(expression=expr), info, frame) + m = info.pydev_message + return None if m is None else ADDR.sub("0x\u2026", m) + + +def hit_in_function(message, env, globals_extra=None, patch_repr=False): + names = list(env) + src = ("def _r(__L, __hook):\n" + "".join(" %s = __L[%r]\n" % (k, k) for k in names) + + " __res = __hook(sys._getframe())\n" + + " return __res, {" + ", ".join("%r: %s" % (k, k) for k in names) + "}\n") + g = {"__builtins__": builtins, "sys": sys} + g.update(globals_extra or {}) + exec(src, g) # builds the frame; the message only ever runs through pydevd's hit + expr = conv(message) + saved = builtins.repr + if patch_repr: + builtins.repr = lambda o: "WRONG" + try: + res, after = g["_r"](env, lambda fr: pydevd_hit(expr, fr)) + finally: + builtins.repr = saved + changed = {k: repr(after[k]) for k in names if after[k] is not env[k] and after[k] != env[k]} + return {"log": res, **({"assigned": changed} if changed else {})} + + +def hit_scopes(message): + expr = conv(message) + + def outer(): + free = "closure" + + def inner(): + local = free + "-local" # noqa: F841 + return pydevd_hit(expr, sys._getframe()) + return inner() + + class C: + local, free = "class-local", "class-free" + res = pydevd_hit(expr, sys._getframe()) + return {"log": "function: %s | class: %s" % (outer(), C.res)} + + +def hit(message, env_name): + if env_name == "scopes": + return hit_scopes(message) + if env_name in ("A", "B"): + return hit_in_function(message, ENV_A if env_name == "A" else ENV_B) + if env_name == "globalY": + return hit_in_function(message, SPECIAL[env_name], globals_extra={"y": 99}) + return hit_in_function(message, SPECIAL[env_name], patch_repr=(env_name == "patchedBuiltinRepr")) + + +def corpus_message(row): + return "{" + "+".join(["1"] * 3000) + "}" if row["msg"] == "DEEP3000" else row["msg"] + + +def run_corpus(): + rows = json.load(open(os.path.join(HERE, "corpus.json"), encoding="utf-8"))["rows"] + out = [] + for row in rows: + m = corpus_message(row) + verdict = check(m) + wire = verdict.get("wire", m) + envs = [row["env"]] if "env" in row else (["scopes"] if row.get("frame") else ["A", "B"]) + rec = {"id": row["id"], "verdict": verdict, "envs": {}} + for e in envs: + if row.get("hit") is False: + # The hit would allocate gigabytes: not run (the checker declines it unformatted). + rec["envs"][e] = {"asWritten": "(not run: the hit would allocate about 2 GB)"} + continue + asw = hit(m, e) + ent = {"asWritten": asw["log"]} + if asw.get("assigned"): + ent["assignedAsWritten"] = asw["assigned"] + if wire != m: + sent = hit(wire, e) + ent["sent"] = sent["log"] + if sent.get("assigned"): + ent["assignedSent"] = sent["assigned"] + rec["envs"][e] = ent + out.append(rec) + return out + + +def run_table(): + rows = json.load(open(os.path.join(HERE, "table.json"), encoding="utf-8"))["rows"] + return [{"key": r["key"], "verdict": check(r["msg"])} for r in rows] + + +class _Matrix: + def __getitem__(self, key): + return "M[%r]" % (key,) + + +def _works_a(expr): + x = "café"; total = 3.5; items = [10, 20, 30, 40]; d = {"a:b": "colon-key", "a": 1} # noqa: E702,F841 + entry = "old"; a = 1; b = 2; w = 10; wd = {"a": 8}; prec = 2; n = 255 # noqa: E702,F841 + dt = datetime.datetime(2026, 11, 28, 13, 45, 7); match = re.match("(a)b", "ab"); case = "C" # noqa: E702,F841 + k = "kk"; v = "vv"; pairs = [("p", 1)]; matrix = _Matrix(); fn = len; ready = True; i = 1 # noqa: E702,F841 + f = (lambda *aa: aa); obj = object; entrée = "é"; land = "L"; minor = 3; literal = 5 # noqa: E702,F841 + y = 0; c = 7; q = 9; p = 8; j = "jj"; matches = ["m"]; r = 7; s = "str"; lam = (lambda *aa: aa) # noqa: E702,F841 + frame = sys._getframe() + return eval(expr, frame.f_globals, frame.f_locals) # what pydevd does at a hit + + +def _works_b(expr): + x = None; total = "3.5"; items = []; d = {}; a = "1"; b = None; i = "three"; n = None # noqa: E702,F841 + entry = None; w = "8"; y = "7"; r = None; s = 5; k = None; v = None; ch = 65; lam = None # noqa: E702,F841 + frame = sys._getframe() + return eval(expr, frame.f_globals, frame.f_locals) + + +def works_as_written(m): + """Whether debugpy's own conversion of m runs without an exception in environment A or B.""" + expr = conv(m) + if expr == repr("Unbalanced braces in: %s" % (m,)): + return False + try: + compile(expr, "", "eval") + except BaseException: # noqa: BLE001 + return False + for run in (_works_a, _works_b): + try: + run(expr) + return True + except BaseException: # noqa: BLE001 + continue + return False + + +PLAUSIBLE = ['joined={"\\n".join(map(str, items))}', 'parts={x.split("\\t")}', "path={'C:\\\\tmp'}", + "{'#'.join(['a', 'b'])}", "count={len(items)} first={items[0]}", "d={d['a:b']}", + "ratio={total / 2:.1%}", "{x!r} {total:>8.2f}", "{x=} {total=}", "100% done {x}", + "{dt:%H:%M}", "{dt.strftime('%H:%M')}", "{ {'k': total} }", "set={ {a, b} }", "{(y := 7)}", + "{y := 7}", "{(lambda v: v)(x)}", "{lambda v: v}", "{{literal}} {x}", "{x # why\n}", + "{items[1:3]}", "{x if ready else total}", "{[i * 2 for i in items]}", "{sorted(d)}", + "{d.get('a:b', '?')}", "{f'{x}!'}", "{f\"{x}\"}", "{'''t'''} {x}"] + + +def percent_set(): + texts = ["%d", "%c", "%f", "%x", "%*s", "%s", "%r", "%%", "%5d", "%-3s", "%.*f", "%(k)s", "% d", "%5%", "%-%", + "% %", "%", "100%", "%%%", "%z", "%ld", "%#o", "%.2f%%"] + groups = ["{1,2}", "{n, x}", "{x}", "{x!r}", "{a, b, w}", "{total:.2f}", "{*items}", "{n, 2, 3}", "{ch, x}"] + out = [] + for t, g in itertools.product(texts, groups): + out += [t + " " + g, g + " " + t, t + g + t] + return out + + +# A starred group: how many elements the tuple has is a value, so the %-test leaves it to the hit. +STARRED = ["%s %s %s {*items}", "%s %s %s %s {*items}", "items %r %r %r {*items}", "{*items}", "%d {*items}"] + + +def generated_sets(): + table = [r["msg"] for r in json.load(open(os.path.join(HERE, "table.json"), encoding="utf-8"))["rows"]] + sets = {"everyday": PLAUSIBLE, "percent-x-groups": percent_set(), "starred": STARRED, "table": table} + limit = sys.getrecursionlimit() + sys.setrecursionlimit(10000) # as #1346's generator ran; the checks below run on the default limit + try: + scale = 10 if QUICK else 1 + sets["fuzz-1"] = fuzz.generate(20000 // scale, 1, conv) + sets["fuzz-2"] = fuzz.generate(40000 // scale, 2, conv) + sets["fuzz-all-3"] = fuzz.generate(60000 // scale, 3, conv, all=True) + finally: + sys.setrecursionlimit(limit) + return sets + + +def run_generated(): + out = {} + for name, msgs in generated_sets().items(): + works = changed = unchecked = 0 + examples = [] + for m in msgs: + v = check(m) + unchecked += v["status"] == "unchecked" + if not works_as_written(m): + continue + works += 1 + if v.get("wire", m) != m: + changed += 1 + if len(examples) < 10: + examples.append({"msg": m, "verdict": v}) + out[name] = {"messages": len(msgs), "worksAsWritten": works, "wireChanged": changed, + "unchecked": unchecked, "examples": examples} + return out + + +# Rows the mutation pass found no corpus row for (the test states what each must give). +EXTRA = [ + "100% {total:.1%}", # a rewritten group holds a % of its own: only the text's % is doubled + "%s %s %s {*items}", # a starred group whose element count makes the template work + "a" * 4100 + "{x!r}", # longer than the message bound: not checked +] + + +def run_extra(): + out = [] + for m in EXTRA: + v = check(m) + wire = v.get("wire", m) + out.append({"status": v["status"], "wire": wire if wire != m else None, "logA": hit(wire, "A")["log"]}) + return out + + +RESOURCE = ["{y:=" + "-" * 3000 + "1}", "{" + "-" * 3500 + "1}"] + + +def run_resource(): + return [{"len": len(m), "verdict": check(m)} for m in RESOURCE] + + +def _ones(n): + return "{" + ",".join(["1"] * n) + "}" + + +def run_bounds(): + worst = "\U0001F600" + "%9999s" * 6 + "%5536s" + k = 8 + while len(worst + "%s" + _ones(k + 1)) <= 4096: + worst += "%s" + k += 1 + cases = { + "review: an emoji, 511 x %9999s, 512 fields": "\U0001F600" + "%9999s" * 511 + _ones(512), + "an emoji, widths adding up to 65,535, then %s to 4,096 characters": worst + _ones(k), + "an emoji, 6 x %.9999f and %.5536f": "\U0001F600" + "%.9999f" * 6 + "%.5536f" + _ones(8), + "%2147483647s {x}": "%2147483647s {x}", + "%10000000s {1,2}": "%10000000s {1,2}", + } + out = {} + for name, m in cases.items(): + tracemalloc.start() + t0 = time.perf_counter() + v = check(m) + elapsed = time.perf_counter() - t0 + _, peak = tracemalloc.get_traced_memory() + tracemalloc.stop() + out[name] = {"len": len(m), "status": v["status"], "wireChanged": v.get("wire", m) != m, + "peakBytes": peak, "ms": round(elapsed * 1000, 3)} + return out + + +started = time.perf_counter() +result = {"python": sys.version.split()[0], "debugpy": str(debugpy.__version__), + "corpus": run_corpus(), "table": run_table(), "resource": run_resource(), "bounds": run_bounds(), + "extra": run_extra()} +result["generated"] = run_generated() +result["seconds"] = round(time.perf_counter() - started, 1) +json.dump(result, open(out_path, "w", encoding="utf-8"), ensure_ascii=True) diff --git a/tests/adapters/python/integration/logpoint-corpus/fuzz.py b/tests/adapters/python/integration/logpoint-corpus/fuzz.py new file mode 100644 index 000000000..2e626a27c --- /dev/null +++ b/tests/adapters/python/integration/logpoint-corpus/fuzz.py @@ -0,0 +1,135 @@ +"""Random Python expressions written as one logpoint group, "{" + expr + "}" (issues #1334, #1349). + +The generator of #1346's fuzz sets, unchanged but for the filter, which asks the installed +debugpy's own conversion instead of a copy of it, and the running interpreter's compile(): the +filtered sets differ between interpreters (the f-string grammar changed in 3.12, and 3.11's +compile() raises SystemError on some of these). emulate.py builds the sets with it: + + generate(20000, 1) messages debugpy's conversion compiles + generate(40000, 2) the same, another seed + generate(60000, 3, all=True) unfiltered: compiling or not + +The expressions use a fixed set of names, numbers and strings, string prefixes, f-strings with +conversions, specs and "=", lambdas, comprehensions, walruses, slices, calls, comments: the +shapes where a model of Python's tokenizer goes wrong. +""" +import random + +NAMES = ["x", "total", "items", "d", "a", "b", "k", "v", "match", "case", "type", "n", "r", "s", "lam", "f"] +NUMS = ["1", "1.5", "1.", "0x1f", "1e3", "1_000", "2j", "0"] +STR_CHARS = ["a", ":", "!", "r", "{", "}", "'", '"', "#", "\\\\", " ", "=", "%", ".2f", "!r", ":>10", "lambda", "\\n"] +PREFIXES = ["", "", "", "r", "b", "rb", "u", "R", "Br"] +FPREFIXES = ["f", "rf", "F", "fR"] +SPEC_PARTS = ["", ">10", ".2f", "^9", "=^9", "'<4", '"<4', "#x", ",", "%H:%M", "!<3", "{w}", ">{w}", ".{p}f"] + + +def rstr(rng, depth): + q = rng.choice(["'", '"', "'''", '"""']) + if rng.random() < 0.3 and depth < 3: + return fstr(rng, depth, q) + pre = rng.choice(PREFIXES) + body = [] + for _ in range(rng.randint(0, 4)): + c = rng.choice(STR_CHARS) + if c in ("'", '"') and len(q) == 1 and c == q: + c = "\\" + c + if pre.lower().startswith("b") or pre.lower() == "rb" or "b" in pre.lower(): + if any(ord(ch) > 127 for ch in c): + c = "a" + body.append(c) + s = "".join(body) + if len(q) == 3 and s.endswith(q[0]): + s += "a" + if s.endswith("\\") and not s.endswith("\\\\"): + s += "\\" + return pre + q + s + q + + +def fstr(rng, depth, q): + pre = rng.choice(FPREFIXES) + parts = [] + for _ in range(rng.randint(1, 3)): + kind = rng.random() + if kind < 0.3: + parts.append(rng.choice(["a", ":", "!r", " ", "{{", "}}", "x=", "%"])) + else: + inner = expr(rng, depth + 1) + field = inner + if rng.random() < 0.2: + field += "=" + if rng.random() < 0.3: + field += "!" + rng.choice("rsa") + if rng.random() < 0.4: + field += ":" + rng.choice(SPEC_PARTS) + # f-string fields must not start with '{' immediately (would read as '{{') + parts.append("{ " + field + "}" if field.startswith("{") else "{" + field + "}") + return pre + q + "".join(parts) + q + + +def atom(rng, depth): + r = rng.random() + if r < 0.4: + return rng.choice(NAMES) + if r < 0.55: + return rng.choice(NUMS) + return rstr(rng, depth) + + +def expr(rng, depth=0): + if depth > 4 or rng.random() < 0.25: + return atom(rng, depth) + e = lambda: expr(rng, depth + 1) # noqa: E731 + forms = [ + lambda: f"{e()} {rng.choice(['+', '-', '*', '!=', '==', '<', 'and', 'or', 'in', 'is not', 'not in', '%'])} {e()}", + lambda: f"not {e()}", + lambda: f"-{e()}", + lambda: f"{e()} if {e()} else {e()}", + lambda: f"lambda: {e()}", + lambda: f"lambda {rng.choice(['q', 'q=' + e(), '*q', 'q, /', '*, q=' + e(), 'q, **kw'])}: {e()}", + lambda: f"({e()})", + lambda: f"[{e()}, {e()}]", + lambda: "{" + f"{e()}: {e()}" + "}", + lambda: "{" + f"{e()}, {e()}" + "}", + lambda: "{" + f"kk: vv for kk, vv in {e()}" + "}", + lambda: f"[vv for vv in {e()} if {e()}]", + lambda: f"{e()}[{e()}]", + lambda: f"{e()}[{rng.choice(['', e()])}:{rng.choice(['', e()])}{rng.choice(['', ':' + e()])}]", + lambda: f"{e()}({e()}, kw={e()})", + lambda: f"{e()}.attr", + lambda: f"(nn := {e()})", + lambda: f"[nn := {e()}, nn]", + lambda: f"[*{e()}]", + lambda: "{" + f"**{e()}" + "}", + lambda: f"f(vv for vv in {e()})", + lambda: f"{e()}(key=lambda vv: {e()})", + lambda: f"({e()}, {e()})", + lambda: f"{e()} # c:!r\n", + lambda: f"(lambda {rng.choice(['q', 'q=' + e()])}: {e()})({e()})", + lambda: f"{e()} if {e()} else lambda: {e()}", + lambda: f"nn := {e()}", + ] + return rng.choice(forms)() + + +def generate(count, seed, conv, all=False): + """`count` distinct messages from `seed`; unless `all`, only those debugpy's conversion compiles.""" + rng = random.Random(seed) + found, tries, seen = [], 0, set() + while len(found) < count and tries < count * 200: + tries += 1 + msg = "{" + expr(rng).strip() + "}" + if msg in seen: + continue + seen.add(msg) + if all: + found.append(msg) + continue + converted = conv(msg) + if converted.startswith("'Unbalanced") or converted.startswith('"Unbalanced'): + continue + try: + compile(converted, "", "eval") + except Exception: # noqa: BLE001 SyntaxError, ValueError; on 3.11 also a SystemError from compile itself + continue + found.append(msg) + return found diff --git a/tests/adapters/python/integration/logpoint-corpus/table.json b/tests/adapters/python/integration/logpoint-corpus/table.json new file mode 100644 index 000000000..76e4510e5 --- /dev/null +++ b/tests/adapters/python/integration/logpoint-corpus/table.json @@ -0,0 +1,8248 @@ +{ + "about": "The 562-row live table of #1346 (357 rows and 205 replacements): per row the message as written and, per interpreter, the verdict of the reviewed rule, the message it sends when that is not the one written (wire), and the line debugpy logs for what was sent (line; null: nothing; an address is written 0x\u2026). Recorded with debugpy 1.8.20 on CPython 3.11.15 and 3.13.12, every line confirmed by a live run.", + "rows": [ + { + "key": "row0", + "msg": "stale={entry!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "stale={f'{entry!r}'}", + "line": "stale='old'" + }, + "3.13": { + "status": "rewritten", + "wire": "stale={f'{entry!r}'}", + "line": "stale='old'" + } + } + }, + { + "key": "fix0", + "msg": "stale={repr(entry)}", + "expect": { + "3.11": { + "status": "runs", + "line": "stale='old'" + }, + "3.13": { + "status": "runs", + "line": "stale='old'" + } + } + }, + { + "key": "row1", + "msg": "{x!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r}'}", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r}'}", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "fix1", + "msg": "{repr(x)}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "row2", + "msg": "{x!s}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!s}'}", + "line": "caf\u00e9" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!s}'}", + "line": "caf\u00e9" + } + } + }, + { + "key": "fix2", + "msg": "{str(x)}", + "expect": { + "3.11": { + "status": "runs", + "line": "caf\u00e9" + }, + "3.13": { + "status": "runs", + "line": "caf\u00e9" + } + } + }, + { + "key": "row3", + "msg": "{x!a}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!a}'}", + "line": "'caf\\xe9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!a}'}", + "line": "'caf\\xe9'" + } + } + }, + { + "key": "fix3", + "msg": "{ascii(x)}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\\xe9'" + }, + "3.13": { + "status": "runs", + "line": "'caf\\xe9'" + } + } + }, + { + "key": "row4", + "msg": "{total:.2f}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{total:.2f}'}", + "line": "3.50" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{total:.2f}'}", + "line": "3.50" + } + } + }, + { + "key": "fix4", + "msg": "{format(total, '.2f')}", + "expect": { + "3.11": { + "status": "runs", + "line": "3.50" + }, + "3.13": { + "status": "runs", + "line": "3.50" + } + } + }, + { + "key": "row5", + "msg": "{x!r:>10}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r:>10}'}", + "line": " 'caf\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r:>10}'}", + "line": " 'caf\u00e9'" + } + } + }, + { + "key": "fix5", + "msg": "{format(repr(x), '>10')}", + "expect": { + "3.11": { + "status": "runs", + "line": " 'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": " 'caf\u00e9'" + } + } + }, + { + "key": "row6", + "msg": "{x != 1}", + "expect": { + "3.11": { + "status": "runs", + "line": "True" + }, + "3.13": { + "status": "runs", + "line": "True" + } + } + }, + { + "key": "row7", + "msg": "{items[1:3]}", + "expect": { + "3.11": { + "status": "runs", + "line": "[20, 30]" + }, + "3.13": { + "status": "runs", + "line": "[20, 30]" + } + } + }, + { + "key": "row8", + "msg": "{d['a:b']}", + "expect": { + "3.11": { + "status": "runs", + "line": "colon-key" + }, + "3.13": { + "status": "runs", + "line": "colon-key" + } + } + }, + { + "key": "row9", + "msg": "{(lambda v: v)(x)}", + "expect": { + "3.11": { + "status": "runs", + "line": "caf\u00e9" + }, + "3.13": { + "status": "runs", + "line": "caf\u00e9" + } + } + }, + { + "key": "row10", + "msg": "{lambda v: v}", + "expect": { + "3.11": { + "status": "runs", + "line": " at 0x\u2026>" + }, + "3.13": { + "status": "runs", + "line": " at 0x\u2026>" + } + } + }, + { + "key": "row11", + "msg": "{y := 7}", + "expect": { + "3.11": { + "status": "runs", + "line": "7" + }, + "3.13": { + "status": "runs", + "line": "7" + } + } + }, + { + "key": "row12", + "msg": "{ {'k': total} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 3.5}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 3.5}" + } + } + }, + { + "key": "row13", + "msg": "{{literal}}", + "expect": { + "3.11": { + "status": "runs", + "line": "{5}" + }, + "3.13": { + "status": "runs", + "line": "{5}" + } + } + }, + { + "key": "row14", + "msg": "{'a!r'}", + "expect": { + "3.11": { + "status": "runs", + "line": "a!r" + }, + "3.13": { + "status": "runs", + "line": "a!r" + } + } + }, + { + "key": "row15", + "msg": "{\"x:y\"}", + "expect": { + "3.11": { + "status": "runs", + "line": "x:y" + }, + "3.13": { + "status": "runs", + "line": "x:y" + } + } + }, + { + "key": "row16", + "msg": "{'x:.2f'}", + "expect": { + "3.11": { + "status": "runs", + "line": "x:.2f" + }, + "3.13": { + "status": "runs", + "line": "x:.2f" + } + } + }, + { + "key": "row17", + "msg": "{'{x!r}'}", + "expect": { + "3.11": { + "status": "runs", + "line": "{x!r}" + }, + "3.13": { + "status": "runs", + "line": "{x!r}" + } + } + }, + { + "key": "row18", + "msg": "{'{}'}", + "expect": { + "3.11": { + "status": "runs", + "line": "{}" + }, + "3.13": { + "status": "runs", + "line": "{}" + } + } + }, + { + "key": "row19", + "msg": "{'{:.2f}'.format(total)}", + "expect": { + "3.11": { + "status": "runs", + "line": "3.50" + }, + "3.13": { + "status": "runs", + "line": "3.50" + } + } + }, + { + "key": "row20", + "msg": "{\"{}:{}\".format(a, b)}", + "expect": { + "3.11": { + "status": "runs", + "line": "1:2" + }, + "3.13": { + "status": "runs", + "line": "1:2" + } + } + }, + { + "key": "row21", + "msg": "{'{}'.format(x)!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"{'{}'.format(x)!r}\"}", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{'{}'.format(x)!r}'}", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "fix21", + "msg": "{repr('{}'.format(x))}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "row22", + "msg": "{'}'}", + "expect": { + "3.11": { + "status": "fails", + "line": "unterminated string literal (detected at line 1) (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "unterminated string literal (detected at line 1) (, line 1)" + } + } + }, + { + "key": "row23", + "msg": "{'{'}", + "expect": { + "3.11": { + "status": "fails", + "line": "Unbalanced braces in: {'{'}" + }, + "3.13": { + "status": "fails", + "line": "Unbalanced braces in: {'{'}" + } + } + }, + { + "key": "row24", + "msg": "{'}' + x!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "unterminated string literal (detected at line 1) (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "unterminated string literal (detected at line 1) (, line 1)" + } + } + }, + { + "key": "row25", + "msg": "{'{' + x!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "Unbalanced braces in: {'{' + x!r}" + }, + "3.13": { + "status": "fails", + "line": "Unbalanced braces in: {'{' + x!r}" + } + } + }, + { + "key": "row26", + "msg": "{'{'} {x!r}}", + "expect": { + "3.11": { + "status": "fails", + "line": "closing parenthesis '}' does not match opening parenthesis '(' (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "closing parenthesis '}' does not match opening parenthesis '(' (, line 1)" + } + } + }, + { + "key": "row27", + "msg": "{f\"{x!r}\"}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "row28", + "msg": "{f'{x!r}'}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "row29", + "msg": "{f'{total:.2f}'}", + "expect": { + "3.11": { + "status": "runs", + "line": "3.50" + }, + "3.13": { + "status": "runs", + "line": "3.50" + } + } + }, + { + "key": "row30", + "msg": "{f\"{x:{w}}\"}", + "expect": { + "3.11": { + "status": "runs", + "line": "caf\u00e9 " + }, + "3.13": { + "status": "runs", + "line": "caf\u00e9 " + } + } + }, + { + "key": "row31", + "msg": "{f\"{x!r:>{w}}\"}", + "expect": { + "3.11": { + "status": "runs", + "line": " 'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": " 'caf\u00e9'" + } + } + }, + { + "key": "row32", + "msg": "{f\"{f'{x!r}'}\"}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "row33", + "msg": "{f'{f\"{total:.2f}\"}'}", + "expect": { + "3.11": { + "status": "runs", + "line": "3.50" + }, + "3.13": { + "status": "runs", + "line": "3.50" + } + } + }, + { + "key": "row34", + "msg": "{f\"{d[\"a:b\"]}\"}", + "expect": { + "3.11": { + "status": "fails", + "line": "f-string: unmatched '[' (, line 1)" + }, + "3.13": { + "status": "runs", + "line": "colon-key" + } + } + }, + { + "key": "row35", + "msg": "{f\"{d[\"a:b\"]!r}\"}", + "expect": { + "3.11": { + "status": "fails", + "line": "f-string: unmatched '[' (, line 1)" + }, + "3.13": { + "status": "runs", + "line": "'colon-key'" + } + } + }, + { + "key": "row36", + "msg": "{f\"{{a:b}}\"}", + "expect": { + "3.11": { + "status": "runs", + "line": "{a:b}" + }, + "3.13": { + "status": "runs", + "line": "{a:b}" + } + } + }, + { + "key": "row37", + "msg": "{f\"{{{x}}}\"}", + "expect": { + "3.11": { + "status": "runs", + "line": "{caf\u00e9}" + }, + "3.13": { + "status": "runs", + "line": "{caf\u00e9}" + } + } + }, + { + "key": "row38", + "msg": "{f\"\\{x}\"}", + "expect": { + "3.11": { + "status": "runs", + "line": "\\caf\u00e9" + }, + "3.13": { + "status": "runs", + "line": "\\caf\u00e9" + } + } + }, + { + "key": "row39", + "msg": "{f'{x:\"<4}'}", + "expect": { + "3.11": { + "status": "runs", + "line": "caf\u00e9" + }, + "3.13": { + "status": "runs", + "line": "caf\u00e9" + } + } + }, + { + "key": "row40", + "msg": "{f\"{x:'^9}\"}", + "expect": { + "3.11": { + "status": "runs", + "line": "''caf\u00e9'''" + }, + "3.13": { + "status": "runs", + "line": "''caf\u00e9'''" + } + } + }, + { + "key": "row41", + "msg": "{f\"{total!=1}\"}", + "expect": { + "3.11": { + "status": "runs", + "line": "True" + }, + "3.13": { + "status": "runs", + "line": "True" + } + } + }, + { + "key": "row42", + "msg": "{f\"{x:=^9}\"}", + "expect": { + "3.11": { + "status": "runs", + "line": "==caf\u00e9===" + }, + "3.13": { + "status": "runs", + "line": "==caf\u00e9===" + } + } + }, + { + "key": "row43", + "msg": "{f\"\\N{EM DASH}\"}", + "expect": { + "3.11": { + "status": "runs", + "line": "\u2014" + }, + "3.13": { + "status": "runs", + "line": "\u2014" + } + } + }, + { + "key": "row44", + "msg": "{rf\"\\N{x}\"}", + "expect": { + "3.11": { + "status": "runs", + "line": "\\Ncaf\u00e9" + }, + "3.13": { + "status": "runs", + "line": "\\Ncaf\u00e9" + } + } + }, + { + "key": "row45", + "msg": "{f\"{x=}\"}", + "expect": { + "3.11": { + "status": "runs", + "line": "x='caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "x='caf\u00e9'" + } + } + }, + { + "key": "row46", + "msg": "{f\"{x=!r:>12}\"}", + "expect": { + "3.11": { + "status": "runs", + "line": "x= 'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "x= 'caf\u00e9'" + } + } + }, + { + "key": "row47", + "msg": "{f'{(lambda: 1)()}'}", + "expect": { + "3.11": { + "status": "runs", + "line": "1" + }, + "3.13": { + "status": "runs", + "line": "1" + } + } + }, + { + "key": "row48", + "msg": "{f'a:b' + x}", + "expect": { + "3.11": { + "status": "runs", + "line": "a:bcaf\u00e9" + }, + "3.13": { + "status": "runs", + "line": "a:bcaf\u00e9" + } + } + }, + { + "key": "row49", + "msg": "{F'{x!r}' + 'c:d'}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9'c:d" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9'c:d" + } + } + }, + { + "key": "row50", + "msg": "{fr'{x!r}:'}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9':" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9':" + } + } + }, + { + "key": "row51", + "msg": "{Rf'{x}:'}", + "expect": { + "3.11": { + "status": "runs", + "line": "caf\u00e9:" + }, + "3.13": { + "status": "runs", + "line": "caf\u00e9:" + } + } + }, + { + "key": "row52", + "msg": "{items[::2]}", + "expect": { + "3.11": { + "status": "runs", + "line": "[10, 30]" + }, + "3.13": { + "status": "runs", + "line": "[10, 30]" + } + } + }, + { + "key": "row53", + "msg": "{items[1:5:2]}", + "expect": { + "3.11": { + "status": "runs", + "line": "[20, 40]" + }, + "3.13": { + "status": "runs", + "line": "[20, 40]" + } + } + }, + { + "key": "row54", + "msg": "{items[::-1]}", + "expect": { + "3.11": { + "status": "runs", + "line": "[40, 30, 20, 10]" + }, + "3.13": { + "status": "runs", + "line": "[40, 30, 20, 10]" + } + } + }, + { + "key": "row55", + "msg": "{items[(i := 1):]}", + "expect": { + "3.11": { + "status": "runs", + "line": "[20, 30, 40]" + }, + "3.13": { + "status": "runs", + "line": "[20, 30, 40]" + } + } + }, + { + "key": "row56", + "msg": "{items[1:3]!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{items[1:3]!r}'}", + "line": "[20, 30]" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{items[1:3]!r}'}", + "line": "[20, 30]" + } + } + }, + { + "key": "fix56", + "msg": "{repr(items[1:3])}", + "expect": { + "3.11": { + "status": "runs", + "line": "[20, 30]" + }, + "3.13": { + "status": "runs", + "line": "[20, 30]" + } + } + }, + { + "key": "row57", + "msg": "{ {k: v for k, v in d.items()} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'a:b': 'colon-key'}" + }, + "3.13": { + "status": "runs", + "line": "{'a:b': 'colon-key'}" + } + } + }, + { + "key": "row58", + "msg": "{ {k: len(v) for k, v in d.items()} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'a:b': 9}" + }, + "3.13": { + "status": "runs", + "line": "{'a:b': 9}" + } + } + }, + { + "key": "row59", + "msg": "{dict((k, v) for k, v in d.items())}", + "expect": { + "3.11": { + "status": "runs", + "line": "{'a:b': 'colon-key'}" + }, + "3.13": { + "status": "runs", + "line": "{'a:b': 'colon-key'}" + } + } + }, + { + "key": "row60", + "msg": "{ {1, 2} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{1, 2}" + }, + "3.13": { + "status": "runs", + "line": "{1, 2}" + } + } + }, + { + "key": "row61", + "msg": "{ {'a': {'b': 1}} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'a': {'b': 1}}" + }, + "3.13": { + "status": "runs", + "line": "{'a': {'b': 1}}" + } + } + }, + { + "key": "row62", + "msg": "{ {**d} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'a:b': 'colon-key'}" + }, + "3.13": { + "status": "runs", + "line": "{'a:b': 'colon-key'}" + } + } + }, + { + "key": "row63", + "msg": "{x if total > 1 else 'no'}", + "expect": { + "3.11": { + "status": "runs", + "line": "caf\u00e9" + }, + "3.13": { + "status": "runs", + "line": "caf\u00e9" + } + } + }, + { + "key": "row64", + "msg": "{'a:b' if x else 'c!r'}", + "expect": { + "3.11": { + "status": "runs", + "line": "a:b" + }, + "3.13": { + "status": "runs", + "line": "a:b" + } + } + }, + { + "key": "row65", + "msg": "{(lambda: 1) if x else (lambda: 2)}", + "expect": { + "3.11": { + "status": "runs", + "line": " at 0x\u2026>" + }, + "3.13": { + "status": "runs", + "line": " at 0x\u2026>" + } + } + }, + { + "key": "row66", + "msg": "{x if total else 0:>8}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x if total else 0:>8}'}", + "line": " caf\u00e9" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x if total else 0:>8}'}", + "line": " caf\u00e9" + } + } + }, + { + "key": "fix66", + "msg": "{format(x if total else 0, '>8')}", + "expect": { + "3.11": { + "status": "runs", + "line": " caf\u00e9" + }, + "3.13": { + "status": "runs", + "line": " caf\u00e9" + } + } + }, + { + "key": "row67", + "msg": "{(lambda v=1: v)()}", + "expect": { + "3.11": { + "status": "runs", + "line": "1" + }, + "3.13": { + "status": "runs", + "line": "1" + } + } + }, + { + "key": "row68", + "msg": "{lambda v=1: v}", + "expect": { + "3.11": { + "status": "runs", + "line": " at 0x\u2026>" + }, + "3.13": { + "status": "runs", + "line": " at 0x\u2026>" + } + } + }, + { + "key": "row69", + "msg": "{(lambda v=d['a:b']: v)()}", + "expect": { + "3.11": { + "status": "runs", + "line": "colon-key" + }, + "3.13": { + "status": "runs", + "line": "colon-key" + } + } + }, + { + "key": "row70", + "msg": "{(lambda v=items[1:3]: v)()}", + "expect": { + "3.11": { + "status": "runs", + "line": "[20, 30]" + }, + "3.13": { + "status": "runs", + "line": "[20, 30]" + } + } + }, + { + "key": "row71", + "msg": "{lambda: 0}", + "expect": { + "3.11": { + "status": "runs", + "line": " at 0x\u2026>" + }, + "3.13": { + "status": "runs", + "line": " at 0x\u2026>" + } + } + }, + { + "key": "row72", + "msg": "{lambda x=lambda a: a: x}", + "expect": { + "3.11": { + "status": "runs", + "line": " at 0x\u2026>" + }, + "3.13": { + "status": "runs", + "line": " at 0x\u2026>" + } + } + }, + { + "key": "row73", + "msg": "{(lambda *, kk=1: kk)()}", + "expect": { + "3.11": { + "status": "runs", + "line": "1" + }, + "3.13": { + "status": "runs", + "line": "1" + } + } + }, + { + "key": "row74", + "msg": "{(lambda *aa, **kw: aa)(1)}", + "expect": { + "3.11": { + "status": "runs", + "line": "(1,)" + }, + "3.13": { + "status": "runs", + "line": "(1,)" + } + } + }, + { + "key": "row75", + "msg": "{(lambda vv, /: vv)(1)}", + "expect": { + "3.11": { + "status": "runs", + "line": "1" + }, + "3.13": { + "status": "runs", + "line": "1" + } + } + }, + { + "key": "row76", + "msg": "{(lambda vv: (ww := vv))(x)}", + "expect": { + "3.11": { + "status": "runs", + "line": "caf\u00e9" + }, + "3.13": { + "status": "runs", + "line": "caf\u00e9" + } + } + }, + { + "key": "row77", + "msg": "{sorted(items, key=lambda vv: -vv)}", + "expect": { + "3.11": { + "status": "runs", + "line": "[40, 30, 20, 10]" + }, + "3.13": { + "status": "runs", + "line": "[40, 30, 20, 10]" + } + } + }, + { + "key": "row78", + "msg": "{lambda vv=1: vv, total}", + "expect": { + "3.11": { + "status": "fails", + "line": "not all arguments converted during string formatting" + }, + "3.13": { + "status": "fails", + "line": "not all arguments converted during string formatting" + } + } + }, + { + "key": "row79", + "msg": "{lambda vv=lambda: 1: vv}", + "expect": { + "3.11": { + "status": "runs", + "line": " at 0x\u2026>" + }, + "3.13": { + "status": "runs", + "line": " at 0x\u2026>" + } + } + }, + { + "key": "row80", + "msg": "{lambda vv={1: 2}: vv}", + "expect": { + "3.11": { + "status": "runs", + "line": " at 0x\u2026>" + }, + "3.13": { + "status": "runs", + "line": " at 0x\u2026>" + } + } + }, + { + "key": "row81", + "msg": "{(lambda v: v)(total):.2f}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{(lambda v: v)(total):.2f}'}", + "line": "3.50" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{(lambda v: v)(total):.2f}'}", + "line": "3.50" + } + } + }, + { + "key": "fix81", + "msg": "{format((lambda v: v)(total), '.2f')}", + "expect": { + "3.11": { + "status": "runs", + "line": "3.50" + }, + "3.13": { + "status": "runs", + "line": "3.50" + } + } + }, + { + "key": "row82", + "msg": "{lambda: x!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "fix82", + "msg": "{repr(lambda: x)}", + "expect": { + "3.11": { + "status": "runs", + "line": " at 0x\u2026>" + }, + "3.13": { + "status": "runs", + "line": " at 0x\u2026>" + } + } + }, + { + "key": "row83", + "msg": "{lambda a, b=1: a + b}", + "expect": { + "3.11": { + "status": "runs", + "line": " at 0x\u2026>" + }, + "3.13": { + "status": "runs", + "line": " at 0x\u2026>" + } + } + }, + { + "key": "row84", + "msg": "{lambda x: lambda y: x + y}", + "expect": { + "3.11": { + "status": "runs", + "line": " at 0x\u2026>" + }, + "3.13": { + "status": "runs", + "line": " at 0x\u2026>" + } + } + }, + { + "key": "row85", + "msg": "{fn if ready else lambda q: q}", + "expect": { + "3.11": { + "status": "runs", + "line": "" + }, + "3.13": { + "status": "runs", + "line": "" + } + } + }, + { + "key": "row86", + "msg": "{(lambda v: int: v)}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row87", + "msg": "{x != 1 != 2}", + "expect": { + "3.11": { + "status": "runs", + "line": "True" + }, + "3.13": { + "status": "runs", + "line": "True" + } + } + }, + { + "key": "row88", + "msg": "{total!=1}", + "expect": { + "3.11": { + "status": "runs", + "line": "True" + }, + "3.13": { + "status": "runs", + "line": "True" + } + } + }, + { + "key": "row89", + "msg": "{a!=b!=x}", + "expect": { + "3.11": { + "status": "runs", + "line": "True" + }, + "3.13": { + "status": "runs", + "line": "True" + } + } + }, + { + "key": "row90", + "msg": "{a!=r}", + "expect": { + "3.11": { + "status": "runs", + "line": "name 'r' is not defined" + }, + "3.13": { + "status": "runs", + "line": "name 'r' is not defined" + } + } + }, + { + "key": "row91", + "msg": "{x != 'r'}", + "expect": { + "3.11": { + "status": "runs", + "line": "True" + }, + "3.13": { + "status": "runs", + "line": "True" + } + } + }, + { + "key": "row92", + "msg": "{'''a:b!r'''}", + "expect": { + "3.11": { + "status": "runs", + "line": "a:b!r" + }, + "3.13": { + "status": "runs", + "line": "a:b!r" + } + } + }, + { + "key": "row93", + "msg": "{\"\"\"x\"y:z\"\"\"}", + "expect": { + "3.11": { + "status": "runs", + "line": "x\"y:z" + }, + "3.13": { + "status": "runs", + "line": "x\"y:z" + } + } + }, + { + "key": "row94", + "msg": "{\"\"\"a:b:.2f\"\"\"}", + "expect": { + "3.11": { + "status": "runs", + "line": "a:b:.2f" + }, + "3.13": { + "status": "runs", + "line": "a:b:.2f" + } + } + }, + { + "key": "row95", + "msg": "{'''it's:''' + x}", + "expect": { + "3.11": { + "status": "runs", + "line": "it's:caf\u00e9" + }, + "3.13": { + "status": "runs", + "line": "it's:caf\u00e9" + } + } + }, + { + "key": "row96", + "msg": "{r'a:b!r'}", + "expect": { + "3.11": { + "status": "runs", + "line": "a:b!r" + }, + "3.13": { + "status": "runs", + "line": "a:b!r" + } + } + }, + { + "key": "row97", + "msg": "{b'a:b'}", + "expect": { + "3.11": { + "status": "runs", + "line": "b'a:b'" + }, + "3.13": { + "status": "runs", + "line": "b'a:b'" + } + } + }, + { + "key": "row98", + "msg": "{rb'a:b'}", + "expect": { + "3.11": { + "status": "runs", + "line": "b'a:b'" + }, + "3.13": { + "status": "runs", + "line": "b'a:b'" + } + } + }, + { + "key": "row99", + "msg": "{Br'a:b'}", + "expect": { + "3.11": { + "status": "runs", + "line": "b'a:b'" + }, + "3.13": { + "status": "runs", + "line": "b'a:b'" + } + } + }, + { + "key": "row100", + "msg": "{u'a:b'}", + "expect": { + "3.11": { + "status": "runs", + "line": "a:b" + }, + "3.13": { + "status": "runs", + "line": "a:b" + } + } + }, + { + "key": "row101", + "msg": "{x # :.2f}", + "expect": { + "3.11": { + "status": "fails", + "line": "'(' was never closed (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "'(' was never closed (, line 1)" + } + } + }, + { + "key": "row102", + "msg": "{x # !r}", + "expect": { + "3.11": { + "status": "fails", + "line": "'(' was never closed (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "'(' was never closed (, line 1)" + } + } + }, + { + "key": "row103", + "msg": "{entr\u00e9e!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{entr\u00e9e!r}'}", + "line": "'\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{entr\u00e9e!r}'}", + "line": "'\u00e9'" + } + } + }, + { + "key": "fix103", + "msg": "{repr(entr\u00e9e)}", + "expect": { + "3.11": { + "status": "runs", + "line": "'\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "'\u00e9'" + } + } + }, + { + "key": "row104", + "msg": "{land!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{land!r}'}", + "line": "'L'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{land!r}'}", + "line": "'L'" + } + } + }, + { + "key": "fix104", + "msg": "{repr(land)}", + "expect": { + "3.11": { + "status": "runs", + "line": "'L'" + }, + "3.13": { + "status": "runs", + "line": "'L'" + } + } + }, + { + "key": "row105", + "msg": "{minor}", + "expect": { + "3.11": { + "status": "runs", + "line": "3" + }, + "3.13": { + "status": "runs", + "line": "3" + } + } + }, + { + "key": "row106", + "msg": "{1.:.2f}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{1.:.2f}'}", + "line": "1.00" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{1.:.2f}'}", + "line": "1.00" + } + } + }, + { + "key": "fix106", + "msg": "{format(1., '.2f')}", + "expect": { + "3.11": { + "status": "runs", + "line": "1.00" + }, + "3.13": { + "status": "runs", + "line": "1.00" + } + } + }, + { + "key": "row107", + "msg": "{1_000:,}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{1_000:,}'}", + "line": "1,000" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{1_000:,}'}", + "line": "1,000" + } + } + }, + { + "key": "fix107", + "msg": "{format(1_000, ',')}", + "expect": { + "3.11": { + "status": "runs", + "line": "1,000" + }, + "3.13": { + "status": "runs", + "line": "1,000" + } + } + }, + { + "key": "row108", + "msg": "{0x1f:#x}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{0x1f:#x}'}", + "line": "0x\u2026" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{0x1f:#x}'}", + "line": "0x\u2026" + } + } + }, + { + "key": "fix108", + "msg": "{format(0x1f, '#x')}", + "expect": { + "3.11": { + "status": "runs", + "line": "0x\u2026" + }, + "3.13": { + "status": "runs", + "line": "0x\u2026" + } + } + }, + { + "key": "row109", + "msg": "{1e3:.1f}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{1e3:.1f}'}", + "line": "1000.0" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{1e3:.1f}'}", + "line": "1000.0" + } + } + }, + { + "key": "fix109", + "msg": "{format(1e3, '.1f')}", + "expect": { + "3.11": { + "status": "runs", + "line": "1000.0" + }, + "3.13": { + "status": "runs", + "line": "1000.0" + } + } + }, + { + "key": "row110", + "msg": "{x, lambda a}{b: a}", + "expect": { + "3.11": { + "status": "runs", + "line": "caf\u00e9 at 0x\u2026>" + }, + "3.13": { + "status": "runs", + "line": "caf\u00e9 at 0x\u2026>" + } + } + }, + { + "key": "row111", + "msg": "{x, total, \"a}{b:c}{\"}", + "expect": { + "3.11": { + "status": "runs", + "line": "caf\u00e93.5a, b:c, " + }, + "3.13": { + "status": "runs", + "line": "caf\u00e93.5a, b:c, " + } + } + }, + { + "key": "row112", + "msg": "{x, total, \"a}{b!r}{\"}", + "expect": { + "3.11": { + "status": "runs", + "line": "caf\u00e93.5a, b!r, " + }, + "3.13": { + "status": "runs", + "line": "caf\u00e93.5a, b!r, " + } + } + }, + { + "key": "row113", + "msg": "{a, d[1}{2:3]}", + "expect": { + "3.11": { + "status": "runs", + "line": "unhashable type: 'slice'" + }, + "3.13": { + "status": "runs", + "line": "(1, slice(2, 3, None))" + } + } + }, + { + "key": "row114", + "msg": "{0, (lambda p}{q: p)(1, 2)}", + "expect": { + "3.11": { + "status": "runs", + "line": "01" + }, + "3.13": { + "status": "runs", + "line": "01" + } + } + }, + { + "key": "row115", + "msg": "{match!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{match!r}'}", + "line": "" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{match!r}'}", + "line": "" + } + } + }, + { + "key": "fix115", + "msg": "{repr(match)}", + "expect": { + "3.11": { + "status": "runs", + "line": "" + }, + "3.13": { + "status": "runs", + "line": "" + } + } + }, + { + "key": "row116", + "msg": "{match.group(0)!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{match.group(0)!r}'}", + "line": "'ab'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{match.group(0)!r}'}", + "line": "'ab'" + } + } + }, + { + "key": "fix116", + "msg": "{repr(match.group(0))}", + "expect": { + "3.11": { + "status": "runs", + "line": "'ab'" + }, + "3.13": { + "status": "runs", + "line": "'ab'" + } + } + }, + { + "key": "row117", + "msg": "{case:>5}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{case:>5}'}", + "line": " C" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{case:>5}'}", + "line": " C" + } + } + }, + { + "key": "fix117", + "msg": "{format(case, '>5')}", + "expect": { + "3.11": { + "status": "runs", + "line": " C" + }, + "3.13": { + "status": "runs", + "line": " C" + } + } + }, + { + "key": "row118", + "msg": "{x=}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x=}'}", + "line": "x='caf\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x=}'}", + "line": "x='caf\u00e9'" + } + } + }, + { + "key": "fix118", + "msg": "x={repr(x)}", + "expect": { + "3.11": { + "status": "runs", + "line": "x='caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "x='caf\u00e9'" + } + } + }, + { + "key": "row119", + "msg": "{x=!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x=!r}'}", + "line": "x='caf\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x=!r}'}", + "line": "x='caf\u00e9'" + } + } + }, + { + "key": "fix119", + "msg": "x={repr(x)}", + "expect": { + "3.11": { + "status": "runs", + "line": "x='caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "x='caf\u00e9'" + } + } + }, + { + "key": "row120", + "msg": "{total=:.2f}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{total=:.2f}'}", + "line": "total=3.50" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{total=:.2f}'}", + "line": "total=3.50" + } + } + }, + { + "key": "fix120", + "msg": "total={format(total, '.2f')}", + "expect": { + "3.11": { + "status": "runs", + "line": "total=3.50" + }, + "3.13": { + "status": "runs", + "line": "total=3.50" + } + } + }, + { + "key": "row121", + "msg": "{len(items)=}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{len(items)=}'}", + "line": "len(items)=4" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{len(items)=}'}", + "line": "len(items)=4" + } + } + }, + { + "key": "fix121", + "msg": "len(items)={repr(len(items))}", + "expect": { + "3.11": { + "status": "runs", + "line": "len(items)=4" + }, + "3.13": { + "status": "runs", + "line": "len(items)=4" + } + } + }, + { + "key": "row122", + "msg": "{x # note}", + "expect": { + "3.11": { + "status": "fails", + "line": "'(' was never closed (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "'(' was never closed (, line 1)" + } + } + }, + { + "key": "row123", + "msg": "{str(x!r)}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row124", + "msg": "{x! r}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row125", + "msg": "{x:=^10}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x:=^10}'}", + "line": "===caf\u00e9===" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x:=^10}'}", + "line": "===caf\u00e9===" + } + } + }, + { + "key": "row126", + "msg": "{x:=10}", + "expect": { + "3.11": { + "status": "runs", + "line": "10" + }, + "3.13": { + "status": "runs", + "line": "10" + } + } + }, + { + "key": "row127", + "msg": "{x!r!s}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row128", + "msg": "{x!}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row129", + "msg": "{a, b}", + "expect": { + "3.11": { + "status": "fails", + "line": "not all arguments converted during string formatting" + }, + "3.13": { + "status": "fails", + "line": "not all arguments converted during string formatting" + } + } + }, + { + "key": "row130", + "msg": "100% {x}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "100%% {x}", + "line": "100% caf\u00e9" + }, + "3.13": { + "status": "rewritten", + "wire": "100%% {x}", + "line": "100% caf\u00e9" + } + } + }, + { + "key": "row131", + "msg": "{x!R}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row132", + "msg": "{type!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{type!r}'}", + "line": "" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{type!r}'}", + "line": "" + } + } + }, + { + "key": "fix132", + "msg": "{repr(type)}", + "expect": { + "3.11": { + "status": "runs", + "line": "" + }, + "3.13": { + "status": "runs", + "line": "" + } + } + }, + { + "key": "row133", + "msg": "{x.!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row134", + "msg": "{!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row135", + "msg": "{:.2f}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid decimal literal (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid decimal literal (, line 1)" + } + } + }, + { + "key": "row136", + "msg": "{\"k\": total}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": total}'}", + "line": "Invalid format specifier ' total' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": total}'}", + "line": "Invalid format specifier ' total' for object of type 'str'" + } + } + }, + { + "key": "fix136", + "msg": "{ {\"k\": total} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 3.5}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 3.5}" + } + } + }, + { + "key": "row137", + "msg": "{k: v}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{k: v}'}", + "line": "Unknown format code 'v' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{k: v}'}", + "line": "Unknown format code 'v' for object of type 'str'" + } + } + }, + { + "key": "fix137-format", + "msg": "{format(k, ' v')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Unknown format code 'v' for object of type 'str'" + }, + "3.13": { + "status": "runs", + "line": "Unknown format code 'v' for object of type 'str'" + } + } + }, + { + "key": "fix137-dict", + "msg": "{ {k: v} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'kk': 'vv'}" + }, + "3.13": { + "status": "runs", + "line": "{'kk': 'vv'}" + } + } + }, + { + "key": "row138", + "msg": "{k: v for k, v in d.items()}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{k: v for k, v in d.items()}'}", + "line": "Invalid format specifier ' v for k, v in d.items()' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{k: v for k, v in d.items()}'}", + "line": "Invalid format specifier ' v for k, v in d.items()' for object of type 'str'" + } + } + }, + { + "key": "fix138", + "msg": "{ {k: v for k, v in d.items()} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'a:b': 'colon-key'}" + }, + "3.13": { + "status": "runs", + "line": "{'a:b': 'colon-key'}" + } + } + }, + { + "key": "row139", + "msg": "{x:{wd['a']}}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"{x:{wd['a']}}\"}", + "line": "caf\u00e9 " + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x:{wd['a']}}'}", + "line": "caf\u00e9 " + } + } + }, + { + "key": "fix139", + "msg": "{format(x, f\"{wd['a']}\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "caf\u00e9 " + }, + "3.13": { + "status": "runs", + "line": "caf\u00e9 " + } + } + }, + { + "key": "row140", + "msg": "{x!r:}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r:}'}", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r:}'}", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "fix140", + "msg": "{format(repr(x), '')}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "row141", + "msg": "{total:}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{total:}'}", + "line": "3.5" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{total:}'}", + "line": "3.5" + } + } + }, + { + "key": "fix141", + "msg": "{format(total, '')}", + "expect": { + "3.11": { + "status": "runs", + "line": "3.5" + }, + "3.13": { + "status": "runs", + "line": "3.5" + } + } + }, + { + "key": "row142", + "msg": "{total:.{prec}f}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{total:.{prec}f}'}", + "line": "3.50" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{total:.{prec}f}'}", + "line": "3.50" + } + } + }, + { + "key": "fix142", + "msg": "{format(total, f'.{prec}f')}", + "expect": { + "3.11": { + "status": "runs", + "line": "3.50" + }, + "3.13": { + "status": "runs", + "line": "3.50" + } + } + }, + { + "key": "row143", + "msg": "{x:>{w}}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x:>{w}}'}", + "line": " caf\u00e9" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x:>{w}}'}", + "line": " caf\u00e9" + } + } + }, + { + "key": "fix143", + "msg": "{format(x, f'>{w}')}", + "expect": { + "3.11": { + "status": "runs", + "line": " caf\u00e9" + }, + "3.13": { + "status": "runs", + "line": " caf\u00e9" + } + } + }, + { + "key": "row144", + "msg": "{x!r:>{w}}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r:>{w}}'}", + "line": " 'caf\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r:>{w}}'}", + "line": " 'caf\u00e9'" + } + } + }, + { + "key": "fix144", + "msg": "{format(repr(x), f'>{w}')}", + "expect": { + "3.11": { + "status": "runs", + "line": " 'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": " 'caf\u00e9'" + } + } + }, + { + "key": "row145", + "msg": "{x:{w}}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x:{w}}'}", + "line": "caf\u00e9 " + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x:{w}}'}", + "line": "caf\u00e9 " + } + } + }, + { + "key": "fix145", + "msg": "{format(x, f'{w}')}", + "expect": { + "3.11": { + "status": "runs", + "line": "caf\u00e9 " + }, + "3.13": { + "status": "runs", + "line": "caf\u00e9 " + } + } + }, + { + "key": "row146", + "msg": "{dt:%H:%M}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{dt:%H:%M}'}", + "line": "13:45" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{dt:%H:%M}'}", + "line": "13:45" + } + } + }, + { + "key": "fix146", + "msg": "{format(dt, '%H:%M')}", + "expect": { + "3.11": { + "status": "runs", + "line": "13:45" + }, + "3.13": { + "status": "runs", + "line": "13:45" + } + } + }, + { + "key": "row147", + "msg": "{n:#08x}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{n:#08x}'}", + "line": "0x\u2026" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{n:#08x}'}", + "line": "0x\u2026" + } + } + }, + { + "key": "fix147", + "msg": "{format(n, '#08x')}", + "expect": { + "3.11": { + "status": "runs", + "line": "0x\u2026" + }, + "3.13": { + "status": "runs", + "line": "0x\u2026" + } + } + }, + { + "key": "row148", + "msg": "{x:'<10}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"{x:'<10}\"}", + "line": "caf\u00e9''''''" + }, + "3.13": { + "status": "rewritten", + "wire": "{f\"{x:'<10}\"}", + "line": "caf\u00e9''''''" + } + } + }, + { + "key": "fix148", + "msg": "{format(x, \"'<10\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "caf\u00e9''''''" + }, + "3.13": { + "status": "runs", + "line": "caf\u00e9''''''" + } + } + }, + { + "key": "row149", + "msg": "{x:\"<10}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x:\"<10}'}", + "line": "caf\u00e9\"\"\"\"\"\"" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x:\"<10}'}", + "line": "caf\u00e9\"\"\"\"\"\"" + } + } + }, + { + "key": "fix149", + "msg": "{format(x, '\"<10')}", + "expect": { + "3.11": { + "status": "runs", + "line": "caf\u00e9\"\"\"\"\"\"" + }, + "3.13": { + "status": "runs", + "line": "caf\u00e9\"\"\"\"\"\"" + } + } + }, + { + "key": "row150", + "msg": "{x:!<10}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x:!<10}'}", + "line": "caf\u00e9!!!!!!" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x:!<10}'}", + "line": "caf\u00e9!!!!!!" + } + } + }, + { + "key": "fix150", + "msg": "{format(x, '!<10')}", + "expect": { + "3.11": { + "status": "runs", + "line": "caf\u00e9!!!!!!" + }, + "3.13": { + "status": "runs", + "line": "caf\u00e9!!!!!!" + } + } + }, + { + "key": "row151", + "msg": "{a, b!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{a, b!r}'}", + "line": "(1, 2)" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{a, b!r}'}", + "line": "(1, 2)" + } + } + }, + { + "key": "fix151", + "msg": "{repr((a, b))}", + "expect": { + "3.11": { + "status": "runs", + "line": "(1, 2)" + }, + "3.13": { + "status": "runs", + "line": "(1, 2)" + } + } + }, + { + "key": "row152", + "msg": "{a, b:>10}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{a, b:>10}'}", + "line": "unsupported format string passed to tuple.__format__" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{a, b:>10}'}", + "line": "unsupported format string passed to tuple.__format__" + } + } + }, + { + "key": "fix152", + "msg": "{format((a, b), '>10')}", + "expect": { + "3.11": { + "status": "runs", + "line": "unsupported format string passed to tuple.__format__" + }, + "3.13": { + "status": "runs", + "line": "unsupported format string passed to tuple.__format__" + } + } + }, + { + "key": "row153", + "msg": "{f(a, b)!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{f(a, b)!r}'}", + "line": "(1, 2)" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f(a, b)!r}'}", + "line": "(1, 2)" + } + } + }, + { + "key": "fix153", + "msg": "{repr(f(a, b))}", + "expect": { + "3.11": { + "status": "runs", + "line": "(1, 2)" + }, + "3.13": { + "status": "runs", + "line": "(1, 2)" + } + } + }, + { + "key": "row154", + "msg": "{x!a:>12}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!a:>12}'}", + "line": " 'caf\\xe9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!a:>12}'}", + "line": " 'caf\\xe9'" + } + } + }, + { + "key": "fix154", + "msg": "{format(ascii(x), '>12')}", + "expect": { + "3.11": { + "status": "runs", + "line": " 'caf\\xe9'" + }, + "3.13": { + "status": "runs", + "line": " 'caf\\xe9'" + } + } + }, + { + "key": "row155", + "msg": "{x!s:^9}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!s:^9}'}", + "line": " caf\u00e9 " + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!s:^9}'}", + "line": " caf\u00e9 " + } + } + }, + { + "key": "fix155", + "msg": "{format(str(x), '^9')}", + "expect": { + "3.11": { + "status": "runs", + "line": " caf\u00e9 " + }, + "3.13": { + "status": "runs", + "line": " caf\u00e9 " + } + } + }, + { + "key": "row156", + "msg": "{ entry !r }", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{ entry !r }'}", + "line": "'old'" + } + } + }, + { + "key": "fix156", + "msg": "{repr(entry)}", + "expect": { + "3.11": { + "status": "runs", + "line": "'old'" + }, + "3.13": { + "status": "runs", + "line": "'old'" + } + } + }, + { + "key": "row157", + "msg": "{d['a:b']:.2f}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"{d['a:b']:.2f}\"}", + "line": "Unknown format code 'f' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{d['a:b']:.2f}'}", + "line": "Unknown format code 'f' for object of type 'str'" + } + } + }, + { + "key": "fix157", + "msg": "{format(d['a:b'], '.2f')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Unknown format code 'f' for object of type 'str'" + }, + "3.13": { + "status": "runs", + "line": "Unknown format code 'f' for object of type 'str'" + } + } + }, + { + "key": "row158", + "msg": "{(y := 3.5):.2f}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{(y := 3.5):.2f}'}", + "line": "3.50" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{(y := 3.5):.2f}'}", + "line": "3.50" + } + } + }, + { + "key": "fix158", + "msg": "{format((y := 3.5), '.2f')}", + "expect": { + "3.11": { + "status": "runs", + "line": "3.50" + }, + "3.13": { + "status": "runs", + "line": "3.50" + } + } + }, + { + "key": "row159", + "msg": "{x:\"'<10}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'''{x:\"'<10}'''}", + "line": "Invalid format specifier '\"'<10' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'''{x:\"'<10}'''}", + "line": "Invalid format specifier '\"'<10' for object of type 'str'" + } + } + }, + { + "key": "fix159", + "msg": "{format(x, '\"\\'<10')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Invalid format specifier '\"'<10' for object of type 'str'" + }, + "3.13": { + "status": "runs", + "line": "Invalid format specifier '\"'<10' for object of type 'str'" + } + } + }, + { + "key": "row160", + "msg": "{x:{w}.{prec}}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x:{w}.{prec}}'}", + "line": "ca " + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x:{w}.{prec}}'}", + "line": "ca " + } + } + }, + { + "key": "fix160", + "msg": "{format(x, f'{w}.{prec}')}", + "expect": { + "3.11": { + "status": "runs", + "line": "ca " + }, + "3.13": { + "status": "runs", + "line": "ca " + } + } + }, + { + "key": "row161", + "msg": "{total:{wd['a']}.{prec}f}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"{total:{wd['a']}.{prec}f}\"}", + "line": " 3.50" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{total:{wd['a']}.{prec}f}'}", + "line": " 3.50" + } + } + }, + { + "key": "fix161", + "msg": "{format(total, f\"{wd['a']}.{prec}f\")}", + "expect": { + "3.11": { + "status": "runs", + "line": " 3.50" + }, + "3.13": { + "status": "runs", + "line": " 3.50" + } + } + }, + { + "key": "row162", + "msg": "{x:{d[\"a:b\"]!r}}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x:{d[\"a:b\"]!r}}'}", + "line": "Invalid format specifier ''colon-key'' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x:{d[\"a:b\"]!r}}'}", + "line": "Invalid format specifier ''colon-key'' for object of type 'str'" + } + } + }, + { + "key": "fix162", + "msg": "{format(x, f'{d[\"a:b\"]!r}')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Invalid format specifier ''colon-key'' for object of type 'str'" + }, + "3.13": { + "status": "runs", + "line": "Invalid format specifier ''colon-key'' for object of type 'str'" + } + } + }, + { + "key": "row163", + "msg": "{x # c\n!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 2)" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x # c\n!r}'}", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "row164", + "msg": "entry={entry!r} total={total:.2f}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "entry={f'{entry!r}'} total={f'{total:.2f}'}", + "line": "entry='old' total=3.50" + }, + "3.13": { + "status": "rewritten", + "wire": "entry={f'{entry!r}'} total={f'{total:.2f}'}", + "line": "entry='old' total=3.50" + } + } + }, + { + "key": "fix164", + "msg": "entry={repr(entry)} total={format(total, '.2f')}", + "expect": { + "3.11": { + "status": "runs", + "line": "entry='old' total=3.50" + }, + "3.13": { + "status": "runs", + "line": "entry='old' total=3.50" + } + } + }, + { + "key": "row165", + "msg": "x={x}, items={items[:2]}", + "expect": { + "3.11": { + "status": "runs", + "line": "x=caf\u00e9, items=[10, 20]" + }, + "3.13": { + "status": "runs", + "line": "x=caf\u00e9, items=[10, 20]" + } + } + }, + { + "key": "row166", + "msg": "items[{i}]={items[i]}", + "expect": { + "3.11": { + "status": "runs", + "line": "items[1]=20" + }, + "3.13": { + "status": "runs", + "line": "items[1]=20" + } + } + }, + { + "key": "row167", + "msg": "ok={x} bad={entry!r} later={total:.2f}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "ok={x} bad={f'{entry!r}'} later={f'{total:.2f}'}", + "line": "ok=caf\u00e9 bad='old' later=3.50" + }, + "3.13": { + "status": "rewritten", + "wire": "ok={x} bad={f'{entry!r}'} later={f'{total:.2f}'}", + "line": "ok=caf\u00e9 bad='old' later=3.50" + } + } + }, + { + "key": "fix167", + "msg": "ok={x} bad={repr(entry)} later={format(total, '.2f')}", + "expect": { + "3.11": { + "status": "runs", + "line": "ok=caf\u00e9 bad='old' later=3.50" + }, + "3.13": { + "status": "runs", + "line": "ok=caf\u00e9 bad='old' later=3.50" + } + } + }, + { + "key": "row168", + "msg": "{n:,} rows", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{n:,}'} rows", + "line": "255 rows" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{n:,}'} rows", + "line": "255 rows" + } + } + }, + { + "key": "fix168", + "msg": "{format(n, ',')} rows", + "expect": { + "3.11": { + "status": "runs", + "line": "255 rows" + }, + "3.13": { + "status": "runs", + "line": "255 rows" + } + } + }, + { + "key": "row169", + "msg": "pct={total/7:.1%}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "pct={f'{total/7:.1%}'}", + "line": "pct=50.0%" + }, + "3.13": { + "status": "rewritten", + "wire": "pct={f'{total/7:.1%}'}", + "line": "pct=50.0%" + } + } + }, + { + "key": "fix169", + "msg": "pct={format(total/7, '.1%')}", + "expect": { + "3.11": { + "status": "runs", + "line": "pct=50.0%" + }, + "3.13": { + "status": "runs", + "line": "pct=50.0%" + } + } + }, + { + "key": "row170", + "msg": "{x!r} at {dt:%Y-%m-%d}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x!r}'} at {f'{dt:%Y-%m-%d}'}", + "line": "'caf\u00e9' at 2026-11-28" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x!r}'} at {f'{dt:%Y-%m-%d}'}", + "line": "'caf\u00e9' at 2026-11-28" + } + } + }, + { + "key": "fix170", + "msg": "{repr(x)} at {format(dt, '%Y-%m-%d')}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9' at 2026-11-28" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9' at 2026-11-28" + } + } + }, + { + "key": "row171", + "msg": "{x}", + "expect": { + "3.11": { + "status": "runs", + "line": "caf\u00e9" + }, + "3.13": { + "status": "runs", + "line": "caf\u00e9" + } + } + }, + { + "key": "row172", + "msg": "{repr(x)}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "row173", + "msg": "{str(x)}", + "expect": { + "3.11": { + "status": "runs", + "line": "caf\u00e9" + }, + "3.13": { + "status": "runs", + "line": "caf\u00e9" + } + } + }, + { + "key": "row174", + "msg": "{ascii(x)}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\\xe9'" + }, + "3.13": { + "status": "runs", + "line": "'caf\\xe9'" + } + } + }, + { + "key": "row175", + "msg": "{format(total, '.2f')}", + "expect": { + "3.11": { + "status": "runs", + "line": "3.50" + }, + "3.13": { + "status": "runs", + "line": "3.50" + } + } + }, + { + "key": "row176", + "msg": "{format(repr(x), '>10')}", + "expect": { + "3.11": { + "status": "runs", + "line": " 'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": " 'caf\u00e9'" + } + } + }, + { + "key": "row177", + "msg": "{matrix[1:3, 2:4]}", + "expect": { + "3.11": { + "status": "runs", + "line": "M[(slice(1, 3, None), slice(2, 4, None))]" + }, + "3.13": { + "status": "runs", + "line": "M[(slice(1, 3, None), slice(2, 4, None))]" + } + } + }, + { + "key": "row178", + "msg": "{(items[1:3])}", + "expect": { + "3.11": { + "status": "runs", + "line": "[20, 30]" + }, + "3.13": { + "status": "runs", + "line": "[20, 30]" + } + } + }, + { + "key": "row179", + "msg": "{d[\"a:b\"]}", + "expect": { + "3.11": { + "status": "runs", + "line": "colon-key" + }, + "3.13": { + "status": "runs", + "line": "colon-key" + } + } + }, + { + "key": "row180", + "msg": "{ {k: v for k, v in pairs} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'p': 1}" + }, + "3.13": { + "status": "runs", + "line": "{'p': 1}" + } + } + }, + { + "key": "row181", + "msg": "{x:=1}", + "expect": { + "3.11": { + "status": "runs", + "line": "1" + }, + "3.13": { + "status": "runs", + "line": "1" + } + } + }, + { + "key": "row182", + "msg": "{land}", + "expect": { + "3.11": { + "status": "runs", + "line": "L" + }, + "3.13": { + "status": "runs", + "line": "L" + } + } + }, + { + "key": "row183", + "msg": "{dt:%Y-%m-%d %H:%M:%S}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{dt:%Y-%m-%d %H:%M:%S}'}", + "line": "2026-11-28 13:45:07" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{dt:%Y-%m-%d %H:%M:%S}'}", + "line": "2026-11-28 13:45:07" + } + } + }, + { + "key": "fix183", + "msg": "{format(dt, '%Y-%m-%d %H:%M:%S')}", + "expect": { + "3.11": { + "status": "runs", + "line": "2026-11-28 13:45:07" + }, + "3.13": { + "status": "runs", + "line": "2026-11-28 13:45:07" + } + } + }, + { + "key": "row184", + "msg": "open {entry!r", + "expect": { + "3.11": { + "status": "fails", + "line": "Unbalanced braces in: open {entry!r" + }, + "3.13": { + "status": "fails", + "line": "Unbalanced braces in: open {entry!r" + } + } + }, + { + "key": "row185", + "msg": "{(entry!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row186", + "msg": "{entry):.2f}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid decimal literal (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid decimal literal (, line 1)" + } + } + }, + { + "key": "row187", + "msg": "{'unterminated:.2f}", + "expect": { + "3.11": { + "status": "fails", + "line": "unterminated string literal (detected at line 1) (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "unterminated string literal (detected at line 1) (, line 1)" + } + } + }, + { + "key": "row188", + "msg": "{entry=!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{entry=!r}'}", + "line": "entry='old'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{entry=!r}'}", + "line": "entry='old'" + } + } + }, + { + "key": "fix188", + "msg": "entry={repr(entry)}", + "expect": { + "3.11": { + "status": "runs", + "line": "entry='old'" + }, + "3.13": { + "status": "runs", + "line": "entry='old'" + } + } + }, + { + "key": "row189", + "msg": "{a + !r}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row190", + "msg": "{obj.:.2f}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid decimal literal (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid decimal literal (, line 1)" + } + } + }, + { + "key": "row191", + "msg": "{if x: y}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row192", + "msg": "{x and:.2f}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid decimal literal (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid decimal literal (, line 1)" + } + } + }, + { + "key": "row193", + "msg": "{lambda x!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row194", + "msg": "{a ! b!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row195", + "msg": "{a ! b:.2f}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid decimal literal (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid decimal literal (, line 1)" + } + } + }, + { + "key": "row196", + "msg": "{x!repr}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row1000", + "msg": "{f\"{x}\"!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{f\"{x}\"!r}'}", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"{x}\"!r}'}", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "fix1000", + "msg": "{repr(f\"{x}\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "row1001", + "msg": "{f\"{x:>{w}}\":^20}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{f\"{x:>{w}}\":^20}'}", + "line": " caf\u00e9 " + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"{x:>{w}}\":^20}'}", + "line": " caf\u00e9 " + } + } + }, + { + "key": "fix1001", + "msg": "{format(f\"{x:>{w}}\", '^20')}", + "expect": { + "3.11": { + "status": "runs", + "line": " caf\u00e9 " + }, + "3.13": { + "status": "runs", + "line": " caf\u00e9 " + } + } + }, + { + "key": "row1002", + "msg": "{f\"{d[\"a:b\"]}\"!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "f-string: unmatched '[' (, line 1)" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"{d[\"a:b\"]}\"!r}'}", + "line": "'colon-key'" + } + } + }, + { + "key": "fix1002", + "msg": "{repr(f\"{d[\"a:b\"]}\")}", + "expect": { + "3.11": { + "status": "fails", + "line": "f-string: unmatched '[' (, line 1)" + }, + "3.13": { + "status": "runs", + "line": "'colon-key'" + } + } + }, + { + "key": "row1003", + "msg": "{f'{x # c\n}'!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "unterminated string literal (detected at line 1) (, line 1)" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f'{x # c\n}'!r}'}", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "fix1003", + "msg": "{repr(f'{x # c\n}')}", + "expect": { + "3.11": { + "status": "fails", + "line": "unterminated string literal (detected at line 1) (, line 1)" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "row1004", + "msg": "{f\"{'a'}\"!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'''{f\"{'a'}\"!r}'''}", + "line": "'a'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"{'a'}\"!r}'}", + "line": "'a'" + } + } + }, + { + "key": "fix1004", + "msg": "{repr(f\"{'a'}\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "'a'" + }, + "3.13": { + "status": "runs", + "line": "'a'" + } + } + }, + { + "key": "row1005", + "msg": "{rf'{x}'!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"{rf'{x}'!r}\"}", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{rf'{x}'!r}'}", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "fix1005", + "msg": "{repr(rf'{x}')}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "row1006", + "msg": "{f\"{x=}\"!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{f\"{x=}\"!r}'}", + "line": "\"x='caf\u00e9'\"" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"{x=}\"!r}'}", + "line": "\"x='caf\u00e9'\"" + } + } + }, + { + "key": "fix1006", + "msg": "{repr(f\"{x=}\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "\"x='caf\u00e9'\"" + }, + "3.13": { + "status": "runs", + "line": "\"x='caf\u00e9'\"" + } + } + }, + { + "key": "row1007", + "msg": "{f\"{ x }\"!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{f\"{ x }\"!r}'}", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"{ x }\"!r}'}", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "fix1007", + "msg": "{repr(f\"{ x }\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "row1008", + "msg": "{f\"{(lambda: 1)()}\"!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{f\"{(lambda: 1)()}\"!r}'}", + "line": "'1'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"{(lambda: 1)()}\"!r}'}", + "line": "'1'" + } + } + }, + { + "key": "fix1008", + "msg": "{repr(f\"{(lambda: 1)()}\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "'1'" + }, + "3.13": { + "status": "runs", + "line": "'1'" + } + } + }, + { + "key": "row1009", + "msg": "{f'''{x}'''!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"{f'''{x}'''!r}\"}", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f'''{x}'''!r}'}", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "fix1009", + "msg": "{repr(f'''{x}''')}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "row1010", + "msg": "{'a\\'b'!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{'a\\'b'!r}'}", + "line": "\"a'b\"" + } + } + }, + { + "key": "fix1010", + "msg": "{repr('a\\'b')}", + "expect": { + "3.11": { + "status": "runs", + "line": "\"a'b\"" + }, + "3.13": { + "status": "runs", + "line": "\"a'b\"" + } + } + }, + { + "key": "row1011", + "msg": "{'''x'y'''!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"{'''x'y'''!r}\"}", + "line": "\"x'y\"" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{'''x'y'''!r}'}", + "line": "\"x'y\"" + } + } + }, + { + "key": "fix1011", + "msg": "{repr('''x'y''')}", + "expect": { + "3.11": { + "status": "runs", + "line": "\"x'y\"" + }, + "3.13": { + "status": "runs", + "line": "\"x'y\"" + } + } + }, + { + "key": "row1012", + "msg": "{\"\"\"a\"b\"\"\"!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"\"\"a\"b\"\"\"!r}'}", + "line": "'a\"b'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"\"\"a\"b\"\"\"!r}'}", + "line": "'a\"b'" + } + } + }, + { + "key": "fix1012", + "msg": "{repr(\"\"\"a\"b\"\"\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "'a\"b'" + }, + "3.13": { + "status": "runs", + "line": "'a\"b'" + } + } + }, + { + "key": "row1013", + "msg": "{rb'a:b'!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"{rb'a:b'!r}\"}", + "line": "b'a:b'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{rb'a:b'!r}'}", + "line": "b'a:b'" + } + } + }, + { + "key": "fix1013", + "msg": "{repr(rb'a:b')}", + "expect": { + "3.11": { + "status": "runs", + "line": "b'a:b'" + }, + "3.13": { + "status": "runs", + "line": "b'a:b'" + } + } + }, + { + "key": "row1014", + "msg": "{fr'{x}:'!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"{fr'{x}:'!r}\"}", + "line": "'caf\u00e9:'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{fr'{x}:'!r}'}", + "line": "'caf\u00e9:'" + } + } + }, + { + "key": "fix1014", + "msg": "{repr(fr'{x}:')}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9:'" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9:'" + } + } + }, + { + "key": "row1015", + "msg": "{Rb'x'!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"{Rb'x'!r}\"}", + "line": "b'x'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{Rb'x'!r}'}", + "line": "b'x'" + } + } + }, + { + "key": "fix1015", + "msg": "{repr(Rb'x')}", + "expect": { + "3.11": { + "status": "runs", + "line": "b'x'" + }, + "3.13": { + "status": "runs", + "line": "b'x'" + } + } + }, + { + "key": "row1016", + "msg": "{f\"{x!r:{w}}\"!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{f\"{x!r:{w}}\"!r}'}", + "line": "\"'caf\u00e9' \"" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"{x!r:{w}}\"!r}'}", + "line": "\"'caf\u00e9' \"" + } + } + }, + { + "key": "fix1016", + "msg": "{repr(f\"{x!r:{w}}\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "\"'caf\u00e9' \"" + }, + "3.13": { + "status": "runs", + "line": "\"'caf\u00e9' \"" + } + } + }, + { + "key": "row1017", + "msg": "{f\"{x:{w}.{prec}}\":>30}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{f\"{x:{w}.{prec}}\":>30}'}", + "line": " ca " + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"{x:{w}.{prec}}\":>30}'}", + "line": " ca " + } + } + }, + { + "key": "fix1017", + "msg": "{format(f\"{x:{w}.{prec}}\", '>30')}", + "expect": { + "3.11": { + "status": "runs", + "line": " ca " + }, + "3.13": { + "status": "runs", + "line": " ca " + } + } + }, + { + "key": "row1018", + "msg": "{f\"{{a}}\"!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{f\"{{a}}\"!r}'}", + "line": "'{a}'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"{{a}}\"!r}'}", + "line": "'{a}'" + } + } + }, + { + "key": "fix1018", + "msg": "{repr(f\"{{a}}\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "'{a}'" + }, + "3.13": { + "status": "runs", + "line": "'{a}'" + } + } + }, + { + "key": "row1019", + "msg": "{f\"\\{x}\"!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"\\{x}\"!r}'}", + "line": "'\\\\caf\u00e9'" + } + } + }, + { + "key": "fix1019", + "msg": "{repr(f\"\\{x}\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "'\\\\caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "'\\\\caf\u00e9'" + } + } + }, + { + "key": "row1020", + "msg": "{f\"{items[1:3]}\"!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{f\"{items[1:3]}\"!r}'}", + "line": "'[20, 30]'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"{items[1:3]}\"!r}'}", + "line": "'[20, 30]'" + } + } + }, + { + "key": "fix1020", + "msg": "{repr(f\"{items[1:3]}\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "'[20, 30]'" + }, + "3.13": { + "status": "runs", + "line": "'[20, 30]'" + } + } + }, + { + "key": "row1021", + "msg": "{f'{x!r}' + 'c:d'!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"{f'{x!r}' + 'c:d'!r}\"}", + "line": "\"'caf\u00e9'c:d\"" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f'{x!r}' + 'c:d'!r}'}", + "line": "\"'caf\u00e9'c:d\"" + } + } + }, + { + "key": "fix1021", + "msg": "{repr(f'{x!r}' + 'c:d')}", + "expect": { + "3.11": { + "status": "runs", + "line": "\"'caf\u00e9'c:d\"" + }, + "3.13": { + "status": "runs", + "line": "\"'caf\u00e9'c:d\"" + } + } + }, + { + "key": "row1022", + "msg": "{f\"{x:=^9}\"!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{f\"{x:=^9}\"!r}'}", + "line": "'==caf\u00e9==='" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"{x:=^9}\"!r}'}", + "line": "'==caf\u00e9==='" + } + } + }, + { + "key": "fix1022", + "msg": "{repr(f\"{x:=^9}\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "'==caf\u00e9==='" + }, + "3.13": { + "status": "runs", + "line": "'==caf\u00e9==='" + } + } + }, + { + "key": "row1023", + "msg": "{t'{x}'!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "fix1023", + "msg": "{repr(t'{x}')}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row1024", + "msg": "{f\"{f'{x}'}\"!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'''{f\"{f'{x}'}\"!r}'''}", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"{f'{x}'}\"!r}'}", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "fix1024", + "msg": "{repr(f\"{f'{x}'}\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "row1025", + "msg": "{b'\\x00'!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{b'\\x00'!r}'}", + "line": "b'\\x00'" + } + } + }, + { + "key": "fix1025", + "msg": "{repr(b'\\x00')}", + "expect": { + "3.11": { + "status": "runs", + "line": "b'\\x00'" + }, + "3.13": { + "status": "runs", + "line": "b'\\x00'" + } + } + }, + { + "key": "row1026", + "msg": "{\"a\\\\\"!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"a\\\\\"!r}'}", + "line": "'a\\\\'" + } + } + }, + { + "key": "fix1026", + "msg": "{repr(\"a\\\\\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "'a\\\\'" + }, + "3.13": { + "status": "runs", + "line": "'a\\\\'" + } + } + }, + { + "key": "row1027", + "msg": "{lambda: f'{x}'!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "fix1027", + "msg": "{repr(lambda: f'{x}')}", + "expect": { + "3.11": { + "status": "runs", + "line": " at 0x\u2026>" + }, + "3.13": { + "status": "runs", + "line": " at 0x\u2026>" + } + } + }, + { + "key": "row1028", + "msg": "{(lambda v: v)(f\"{x}\")!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{(lambda v: v)(f\"{x}\")!r}'}", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{(lambda v: v)(f\"{x}\")!r}'}", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "fix1028", + "msg": "{repr((lambda v: v)(f\"{x}\"))}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "row1029", + "msg": "{'''a\nb'''!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"\"\"{'''a\nb'''!r}\"\"\"}", + "line": "'a\\nb'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{'''a\nb'''!r}'}", + "line": "'a\\nb'" + } + } + }, + { + "key": "fix1029", + "msg": "{repr('''a\nb''')}", + "expect": { + "3.11": { + "status": "runs", + "line": "'a\\nb'" + }, + "3.13": { + "status": "runs", + "line": "'a\\nb'" + } + } + }, + { + "key": "row1030", + "msg": "{f'{x!r:\"<4}'!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'''{f'{x!r:\"<4}'!r}'''}", + "line": "\"'caf\u00e9'\"" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f'{x!r:\"<4}'!r}'}", + "line": "\"'caf\u00e9'\"" + } + } + }, + { + "key": "fix1030", + "msg": "{repr(f'{x!r:\"<4}')}", + "expect": { + "3.11": { + "status": "runs", + "line": "\"'caf\u00e9'\"" + }, + "3.13": { + "status": "runs", + "line": "\"'caf\u00e9'\"" + } + } + }, + { + "key": "row1031", + "msg": "{f'{x:{\"<\"}10}'!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'''{f'{x:{\"<\"}10}'!r}'''}", + "line": "'caf\u00e9 '" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f'{x:{\"<\"}10}'!r}'}", + "line": "'caf\u00e9 '" + } + } + }, + { + "key": "fix1031", + "msg": "{repr(f'{x:{\"<\"}10}')}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9 '" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9 '" + } + } + }, + { + "key": "row1032", + "msg": "{f\"\"\"{x}\n\"\"\"!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'''{f\"\"\"{x}\n\"\"\"!r}'''}", + "line": "'caf\u00e9\\n'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"\"\"{x}\n\"\"\"!r}'}", + "line": "'caf\u00e9\\n'" + } + } + }, + { + "key": "fix1032", + "msg": "{repr(f\"\"\"{x}\n\"\"\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9\\n'" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9\\n'" + } + } + }, + { + "key": "row2000", + "msg": "{x=}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x=}'}", + "line": "x='caf\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x=}'}", + "line": "x='caf\u00e9'" + } + } + }, + { + "key": "fix2000", + "msg": "x={repr(x)}", + "expect": { + "3.11": { + "status": "runs", + "line": "x='caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "x='caf\u00e9'" + } + } + }, + { + "key": "row2001", + "msg": "{ x = }", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{ x = }'}", + "line": " x = 'caf\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{ x = }'}", + "line": " x = 'caf\u00e9'" + } + } + }, + { + "key": "fix2001", + "msg": " x = {repr(x)}", + "expect": { + "3.11": { + "status": "runs", + "line": " x = 'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": " x = 'caf\u00e9'" + } + } + }, + { + "key": "row2002", + "msg": "{x=!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x=!r}'}", + "line": "x='caf\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x=!r}'}", + "line": "x='caf\u00e9'" + } + } + }, + { + "key": "fix2002", + "msg": "x={repr(x)}", + "expect": { + "3.11": { + "status": "runs", + "line": "x='caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "x='caf\u00e9'" + } + } + }, + { + "key": "row2003", + "msg": "{x=!s}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x=!s}'}", + "line": "x=caf\u00e9" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x=!s}'}", + "line": "x=caf\u00e9" + } + } + }, + { + "key": "fix2003", + "msg": "x={str(x)}", + "expect": { + "3.11": { + "status": "runs", + "line": "x=caf\u00e9" + }, + "3.13": { + "status": "runs", + "line": "x=caf\u00e9" + } + } + }, + { + "key": "row2004", + "msg": "{x=!a}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x=!a}'}", + "line": "x='caf\\xe9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x=!a}'}", + "line": "x='caf\\xe9'" + } + } + }, + { + "key": "fix2004", + "msg": "x={ascii(x)}", + "expect": { + "3.11": { + "status": "runs", + "line": "x='caf\\xe9'" + }, + "3.13": { + "status": "runs", + "line": "x='caf\\xe9'" + } + } + }, + { + "key": "row2005", + "msg": "stale={entry=!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "stale={f'{entry=!r}'}", + "line": "stale=entry='old'" + }, + "3.13": { + "status": "rewritten", + "wire": "stale={f'{entry=!r}'}", + "line": "stale=entry='old'" + } + } + }, + { + "key": "fix2005", + "msg": "stale=entry={repr(entry)}", + "expect": { + "3.11": { + "status": "runs", + "line": "stale=entry='old'" + }, + "3.13": { + "status": "runs", + "line": "stale=entry='old'" + } + } + }, + { + "key": "row2006", + "msg": "{total=:.2f}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{total=:.2f}'}", + "line": "total=3.50" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{total=:.2f}'}", + "line": "total=3.50" + } + } + }, + { + "key": "fix2006", + "msg": "total={format(total, '.2f')}", + "expect": { + "3.11": { + "status": "runs", + "line": "total=3.50" + }, + "3.13": { + "status": "runs", + "line": "total=3.50" + } + } + }, + { + "key": "row2007", + "msg": "{x=:>10}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x=:>10}'}", + "line": "x= caf\u00e9" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x=:>10}'}", + "line": "x= caf\u00e9" + } + } + }, + { + "key": "fix2007", + "msg": "x={format(x, '>10')}", + "expect": { + "3.11": { + "status": "runs", + "line": "x= caf\u00e9" + }, + "3.13": { + "status": "runs", + "line": "x= caf\u00e9" + } + } + }, + { + "key": "row2008", + "msg": "{x=!r:>10}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x=!r:>10}'}", + "line": "x= 'caf\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x=!r:>10}'}", + "line": "x= 'caf\u00e9'" + } + } + }, + { + "key": "fix2008", + "msg": "x={format(repr(x), '>10')}", + "expect": { + "3.11": { + "status": "runs", + "line": "x= 'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "x= 'caf\u00e9'" + } + } + }, + { + "key": "row2009", + "msg": "{len(items)=}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{len(items)=}'}", + "line": "len(items)=4" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{len(items)=}'}", + "line": "len(items)=4" + } + } + }, + { + "key": "fix2009", + "msg": "len(items)={repr(len(items))}", + "expect": { + "3.11": { + "status": "runs", + "line": "len(items)=4" + }, + "3.13": { + "status": "runs", + "line": "len(items)=4" + } + } + }, + { + "key": "row2010", + "msg": "{a == b=}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{a == b=}'}", + "line": "a == b=False" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{a == b=}'}", + "line": "a == b=False" + } + } + }, + { + "key": "fix2010", + "msg": "a == b={repr(a == b)}", + "expect": { + "3.11": { + "status": "runs", + "line": "a == b=False" + }, + "3.13": { + "status": "runs", + "line": "a == b=False" + } + } + }, + { + "key": "row2011", + "msg": "{a, b=}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{a, b=}'}", + "line": "a, b=(1, 2)" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{a, b=}'}", + "line": "a, b=(1, 2)" + } + } + }, + { + "key": "fix2011", + "msg": "a, b={repr((a, b))}", + "expect": { + "3.11": { + "status": "runs", + "line": "a, b=(1, 2)" + }, + "3.13": { + "status": "runs", + "line": "a, b=(1, 2)" + } + } + }, + { + "key": "row2012", + "msg": "{x=:}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x=:}'}", + "line": "x=caf\u00e9" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x=:}'}", + "line": "x=caf\u00e9" + } + } + }, + { + "key": "fix2012", + "msg": "x={format(x, '')}", + "expect": { + "3.11": { + "status": "runs", + "line": "x=caf\u00e9" + }, + "3.13": { + "status": "runs", + "line": "x=caf\u00e9" + } + } + }, + { + "key": "row2013", + "msg": "{x= !r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x= !r}'}", + "line": "x= 'caf\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x= !r}'}", + "line": "x= 'caf\u00e9'" + } + } + }, + { + "key": "fix2013", + "msg": "x= {repr(x)}", + "expect": { + "3.11": { + "status": "runs", + "line": "x= 'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "x= 'caf\u00e9'" + } + } + }, + { + "key": "row2014", + "msg": "{d['a:b']=}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"{d['a:b']=}\"}", + "line": "d['a:b']='colon-key'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{d['a:b']=}'}", + "line": "d['a:b']='colon-key'" + } + } + }, + { + "key": "fix2014", + "msg": "d['a:b']={repr(d['a:b'])}", + "expect": { + "3.11": { + "status": "runs", + "line": "d['a:b']='colon-key'" + }, + "3.13": { + "status": "runs", + "line": "d['a:b']='colon-key'" + } + } + }, + { + "key": "row2015", + "msg": "{ {1: 2}[1]=}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{ {1: 2}[1]=}'}", + "line": " {1: 2}[1]=2" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{ {1: 2}[1]=}'}", + "line": " {1: 2}[1]=2" + } + } + }, + { + "key": "fix2015", + "msg": "{' {1: 2}[1]='}{repr({1: 2}[1])}", + "expect": { + "3.11": { + "status": "runs", + "line": " {1: 2}[1]=2" + }, + "3.13": { + "status": "runs", + "line": " {1: 2}[1]=2" + } + } + }, + { + "key": "row2016", + "msg": "{total % 2=}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{total % 2=}'}", + "line": "total % 2=1.5" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{total % 2=}'}", + "line": "total % 2=1.5" + } + } + }, + { + "key": "fix2016", + "msg": "{'total % 2='}{repr(total % 2)}", + "expect": { + "3.11": { + "status": "runs", + "line": "total % 2=1.5" + }, + "3.13": { + "status": "runs", + "line": "total % 2=1.5" + } + } + }, + { + "key": "row2017", + "msg": "{match=}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{match=}'}", + "line": "match=" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{match=}'}", + "line": "match=" + } + } + }, + { + "key": "fix2017", + "msg": "match={repr(match)}", + "expect": { + "3.11": { + "status": "runs", + "line": "match=" + }, + "3.13": { + "status": "runs", + "line": "match=" + } + } + }, + { + "key": "row2018", + "msg": "{x=:{w}}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x=:{w}}'}", + "line": "x=caf\u00e9 " + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x=:{w}}'}", + "line": "x=caf\u00e9 " + } + } + }, + { + "key": "fix2018", + "msg": "x={format(x, f'{w}')}", + "expect": { + "3.11": { + "status": "runs", + "line": "x=caf\u00e9 " + }, + "3.13": { + "status": "runs", + "line": "x=caf\u00e9 " + } + } + }, + { + "key": "row2019", + "msg": "{(y := 3)=}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{(y := 3)=}'}", + "line": "(y := 3)=3" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{(y := 3)=}'}", + "line": "(y := 3)=3" + } + } + }, + { + "key": "fix2019", + "msg": "(y := 3)={repr((y := 3))}", + "expect": { + "3.11": { + "status": "runs", + "line": "(y := 3)=3" + }, + "3.13": { + "status": "runs", + "line": "(y := 3)=3" + } + } + }, + { + "key": "row2020", + "msg": "{a == b}", + "expect": { + "3.11": { + "status": "runs", + "line": "False" + }, + "3.13": { + "status": "runs", + "line": "False" + } + } + }, + { + "key": "row2021", + "msg": "{a <= b}", + "expect": { + "3.11": { + "status": "runs", + "line": "True" + }, + "3.13": { + "status": "runs", + "line": "True" + } + } + }, + { + "key": "row2022", + "msg": "{a != b}", + "expect": { + "3.11": { + "status": "runs", + "line": "True" + }, + "3.13": { + "status": "runs", + "line": "True" + } + } + }, + { + "key": "row2023", + "msg": "{a >= b}", + "expect": { + "3.11": { + "status": "runs", + "line": "False" + }, + "3.13": { + "status": "runs", + "line": "False" + } + } + }, + { + "key": "row2024", + "msg": "{y := 5}", + "expect": { + "3.11": { + "status": "runs", + "line": "5" + }, + "3.13": { + "status": "runs", + "line": "5" + } + } + }, + { + "key": "row2025", + "msg": "{dict(a=1)}", + "expect": { + "3.11": { + "status": "runs", + "line": "{'a': 1}" + }, + "3.13": { + "status": "runs", + "line": "{'a': 1}" + } + } + }, + { + "key": "row2026", + "msg": "{sorted(items, reverse=True)}", + "expect": { + "3.11": { + "status": "runs", + "line": "[40, 30, 20, 10]" + }, + "3.13": { + "status": "runs", + "line": "[40, 30, 20, 10]" + } + } + }, + { + "key": "row2027", + "msg": "{x==}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row2028", + "msg": "{x+=}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row2029", + "msg": "{x:=}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x:=}'}", + "line": "'=' alignment not allowed in string format specifier" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x:=}'}", + "line": "'=' alignment not allowed in string format specifier" + } + } + }, + { + "key": "row2030", + "msg": "{=}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row2031", + "msg": "{\"k\": total}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": total}'}", + "line": "Invalid format specifier ' total' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": total}'}", + "line": "Invalid format specifier ' total' for object of type 'str'" + } + } + }, + { + "key": "fix2031", + "msg": "{ {\"k\": total} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 3.5}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 3.5}" + } + } + }, + { + "key": "row2032", + "msg": "{'a': 1, 'b': 2}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"{'a': 1, 'b': 2}\"}", + "line": "Invalid format specifier ' 1, 'b': 2' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f\"{'a': 1, 'b': 2}\"}", + "line": "Invalid format specifier ' 1, 'b': 2' for object of type 'str'" + } + } + }, + { + "key": "fix2032", + "msg": "{ {'a': 1, 'b': 2} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'a': 1, 'b': 2}" + }, + "3.13": { + "status": "runs", + "line": "{'a': 1, 'b': 2}" + } + } + }, + { + "key": "row2033", + "msg": "{1: 'a'}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"{1: 'a'}\"}", + "line": "Invalid format specifier ' 'a'' for object of type 'int'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f\"{1: 'a'}\"}", + "line": "Invalid format specifier ' 'a'' for object of type 'int'" + } + } + }, + { + "key": "fix2033-format", + "msg": "{format(1, \" 'a'\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "Invalid format specifier ' 'a'' for object of type 'int'" + }, + "3.13": { + "status": "runs", + "line": "Invalid format specifier ' 'a'' for object of type 'int'" + } + } + }, + { + "key": "fix2033-dict", + "msg": "{ {1: 'a'} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{1: 'a'}" + }, + "3.13": { + "status": "runs", + "line": "{1: 'a'}" + } + } + }, + { + "key": "row2034", + "msg": "{\"k\":total}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\":total}'}", + "line": "Invalid format specifier 'total' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\":total}'}", + "line": "Invalid format specifier 'total' for object of type 'str'" + } + } + }, + { + "key": "fix2034", + "msg": "{ {\"k\":total} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 3.5}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 3.5}" + } + } + }, + { + "key": "row2035", + "msg": "{k: v}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{k: v}'}", + "line": "Unknown format code 'v' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{k: v}'}", + "line": "Unknown format code 'v' for object of type 'str'" + } + } + }, + { + "key": "fix2035-format", + "msg": "{format(k, ' v')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Unknown format code 'v' for object of type 'str'" + }, + "3.13": { + "status": "runs", + "line": "Unknown format code 'v' for object of type 'str'" + } + } + }, + { + "key": "fix2035-dict", + "msg": "{ {k: v} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'kk': 'vv'}" + }, + "3.13": { + "status": "runs", + "line": "{'kk': 'vv'}" + } + } + }, + { + "key": "row2036", + "msg": "{k: v for k, v in d.items()}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{k: v for k, v in d.items()}'}", + "line": "Invalid format specifier ' v for k, v in d.items()' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{k: v for k, v in d.items()}'}", + "line": "Invalid format specifier ' v for k, v in d.items()' for object of type 'str'" + } + } + }, + { + "key": "fix2036", + "msg": "{ {k: v for k, v in d.items()} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'a:b': 'colon-key'}" + }, + "3.13": { + "status": "runs", + "line": "{'a:b': 'colon-key'}" + } + } + }, + { + "key": "row2037", + "msg": "{\"k\": 5}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": 5}'}", + "line": "Space not allowed in string format specifier" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": 5}'}", + "line": "Space not allowed in string format specifier" + } + } + }, + { + "key": "fix2037", + "msg": "{ {\"k\": 5} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 5}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 5}" + } + } + }, + { + "key": "row2038", + "msg": "{k: lambda: 1}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{k: lambda: 1}'}", + "line": "Invalid format specifier ' lambda: 1' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{k: lambda: 1}'}", + "line": "Invalid format specifier ' lambda: 1' for object of type 'str'" + } + } + }, + { + "key": "fix2038-format", + "msg": "{format(k, ' lambda: 1')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Invalid format specifier ' lambda: 1' for object of type 'str'" + }, + "3.13": { + "status": "runs", + "line": "Invalid format specifier ' lambda: 1' for object of type 'str'" + } + } + }, + { + "key": "fix2038-dict", + "msg": "{ {k: lambda: 1} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'kk': at 0x\u2026>}" + }, + "3.13": { + "status": "runs", + "line": "{'kk': at 0x\u2026>}" + } + } + }, + { + "key": "row2039", + "msg": "{**d, \"k\": 1}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "fix2039", + "msg": "{ {**d, \"k\": 1} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'a:b': 'colon-key', 'k': 1}" + }, + "3.13": { + "status": "runs", + "line": "{'a:b': 'colon-key', 'k': 1}" + } + } + }, + { + "key": "row2040", + "msg": "{\"a\": {\"b\": 1}}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"a\": {\"b\": 1}}'}", + "line": "Space not allowed in string format specifier" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"a\": {\"b\": 1}}'}", + "line": "Space not allowed in string format specifier" + } + } + }, + { + "key": "fix2040", + "msg": "{ {\"a\": {\"b\": 1}} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'a': {'b': 1}}" + }, + "3.13": { + "status": "runs", + "line": "{'a': {'b': 1}}" + } + } + }, + { + "key": "row2041", + "msg": "{x:10}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x:10}'}", + "line": "caf\u00e9 " + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x:10}'}", + "line": "caf\u00e9 " + } + } + }, + { + "key": "fix2041", + "msg": "{format(x, '10')}", + "expect": { + "3.11": { + "status": "runs", + "line": "caf\u00e9 " + }, + "3.13": { + "status": "runs", + "line": "caf\u00e9 " + } + } + }, + { + "key": "row2042", + "msg": "{x:{w}}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x:{w}}'}", + "line": "caf\u00e9 " + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x:{w}}'}", + "line": "caf\u00e9 " + } + } + }, + { + "key": "fix2042", + "msg": "{format(x, f'{w}')}", + "expect": { + "3.11": { + "status": "runs", + "line": "caf\u00e9 " + }, + "3.13": { + "status": "runs", + "line": "caf\u00e9 " + } + } + }, + { + "key": "row2043", + "msg": "{\"k\": total,}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": total,}'}", + "line": "Invalid format specifier ' total,' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": total,}'}", + "line": "Invalid format specifier ' total,' for object of type 'str'" + } + } + }, + { + "key": "fix2043", + "msg": "{ {\"k\": total,} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 3.5}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 3.5}" + } + } + }, + { + "key": "row2044", + "msg": "{k: v, j}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{k: v, j}'}", + "line": "Invalid format specifier ' v, j' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{k: v, j}'}", + "line": "Invalid format specifier ' v, j' for object of type 'str'" + } + } + }, + { + "key": "fix2044", + "msg": "{format(k, ' v, j')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Invalid format specifier ' v, j' for object of type 'str'" + }, + "3.13": { + "status": "runs", + "line": "Invalid format specifier ' v, j' for object of type 'str'" + } + } + }, + { + "key": "row2045", + "msg": "{match!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{match!r}'}", + "line": "" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{match!r}'}", + "line": "" + } + } + }, + { + "key": "fix2045", + "msg": "{repr(match)}", + "expect": { + "3.11": { + "status": "runs", + "line": "" + }, + "3.13": { + "status": "runs", + "line": "" + } + } + }, + { + "key": "row2046", + "msg": "{match.group(0)!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{match.group(0)!r}'}", + "line": "'ab'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{match.group(0)!r}'}", + "line": "'ab'" + } + } + }, + { + "key": "fix2046", + "msg": "{repr(match.group(0))}", + "expect": { + "3.11": { + "status": "runs", + "line": "'ab'" + }, + "3.13": { + "status": "runs", + "line": "'ab'" + } + } + }, + { + "key": "row2047", + "msg": "{case:>5}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{case:>5}'}", + "line": " C" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{case:>5}'}", + "line": " C" + } + } + }, + { + "key": "fix2047", + "msg": "{format(case, '>5')}", + "expect": { + "3.11": { + "status": "runs", + "line": " C" + }, + "3.13": { + "status": "runs", + "line": " C" + } + } + }, + { + "key": "row2048", + "msg": "{matches!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{matches!r}'}", + "line": "['m']" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{matches!r}'}", + "line": "['m']" + } + } + }, + { + "key": "fix2048", + "msg": "{repr(matches)}", + "expect": { + "3.11": { + "status": "runs", + "line": "['m']" + }, + "3.13": { + "status": "runs", + "line": "['m']" + } + } + }, + { + "key": "row2049", + "msg": "entry={entry!r} total={total:.2f}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "entry={f'{entry!r}'} total={f'{total:.2f}'}", + "line": "entry='old' total=3.50" + }, + "3.13": { + "status": "rewritten", + "wire": "entry={f'{entry!r}'} total={f'{total:.2f}'}", + "line": "entry='old' total=3.50" + } + } + }, + { + "key": "fix2049", + "msg": "entry={repr(entry)} total={format(total, '.2f')}", + "expect": { + "3.11": { + "status": "runs", + "line": "entry='old' total=3.50" + }, + "3.13": { + "status": "runs", + "line": "entry='old' total=3.50" + } + } + }, + { + "key": "row2050", + "msg": "{a!r} {b!r} {x!r} {total!r} {entry!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{a!r}'} {f'{b!r}'} {f'{x!r}'} {f'{total!r}'} {f'{entry!r}'}", + "line": "1 2 'caf\u00e9' 3.5 'old'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{a!r}'} {f'{b!r}'} {f'{x!r}'} {f'{total!r}'} {f'{entry!r}'}", + "line": "1 2 'caf\u00e9' 3.5 'old'" + } + } + }, + { + "key": "fix2050", + "msg": "{repr(a)} {repr(b)} {repr(x)} {total!r} {entry!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{repr(a)} {repr(b)} {repr(x)} {f'{total!r}'} {f'{entry!r}'}", + "line": "1 2 'caf\u00e9' 3.5 'old'" + }, + "3.13": { + "status": "rewritten", + "wire": "{repr(a)} {repr(b)} {repr(x)} {f'{total!r}'} {f'{entry!r}'}", + "line": "1 2 'caf\u00e9' 3.5 'old'" + } + } + }, + { + "key": "row2051", + "msg": "{a!r} {b!r} {x!r} {total!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{a!r}'} {f'{b!r}'} {f'{x!r}'} {f'{total!r}'}", + "line": "1 2 'caf\u00e9' 3.5" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{a!r}'} {f'{b!r}'} {f'{x!r}'} {f'{total!r}'}", + "line": "1 2 'caf\u00e9' 3.5" + } + } + }, + { + "key": "fix2051", + "msg": "{repr(a)} {repr(b)} {repr(x)} {total!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{repr(a)} {repr(b)} {repr(x)} {f'{total!r}'}", + "line": "1 2 'caf\u00e9' 3.5" + }, + "3.13": { + "status": "rewritten", + "wire": "{repr(a)} {repr(b)} {repr(x)} {f'{total!r}'}", + "line": "1 2 'caf\u00e9' 3.5" + } + } + }, + { + "key": "row2052", + "msg": "{x, lambda a}{b: a} {x!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row2053", + "msg": "{x!r} {x, lambda a}{b: a}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "fix2053", + "msg": "{repr(x)} {x, lambda a}{b: a}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9' caf\u00e9 at 0x\u2026>" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9' caf\u00e9 at 0x\u2026>" + } + } + }, + { + "key": "row2054", + "msg": "{dt:%H\\%M}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{dt:%H\\%M}'}", + "line": "13\\45" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{dt:%H\\%M}'}", + "line": "13\\45" + } + } + }, + { + "key": "fix2054", + "msg": "{format(dt, '%H\\\\%M')}", + "expect": { + "3.11": { + "status": "runs", + "line": "13\\45" + }, + "3.13": { + "status": "runs", + "line": "13\\45" + } + } + }, + { + "key": "row2055", + "msg": "{dt:%H\n%M}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'''{dt:%H\n%M}'''}", + "line": "13\n45" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'''{dt:%H\n%M}'''}", + "line": "13\n45" + } + } + }, + { + "key": "fix2055", + "msg": "{format(dt, '%H\\n%M')}", + "expect": { + "3.11": { + "status": "runs", + "line": "13\n45" + }, + "3.13": { + "status": "runs", + "line": "13\n45" + } + } + }, + { + "key": "row2056", + "msg": "{dt:%H\t%M}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{dt:%H\t%M}'}", + "line": "13\t45" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{dt:%H\t%M}'}", + "line": "13\t45" + } + } + }, + { + "key": "fix2056", + "msg": "{format(dt, '%H\\t%M')}", + "expect": { + "3.11": { + "status": "runs", + "line": "13\t45" + }, + "3.13": { + "status": "runs", + "line": "13\t45" + } + } + }, + { + "key": "row2057", + "msg": "{dt:%H\r%M}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'''{dt:%H\r%M}'''}", + "line": "13\n45" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'''{dt:%H\r%M}'''}", + "line": "13\n45" + } + } + }, + { + "key": "fix2057", + "msg": "{format(dt, '%H\\r%M')}", + "expect": { + "3.11": { + "status": "runs", + "line": "13\r45" + }, + "3.13": { + "status": "runs", + "line": "13\r45" + } + } + }, + { + "key": "row2058", + "msg": "{...!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{...!r}'}", + "line": "Ellipsis" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{...!r}'}", + "line": "Ellipsis" + } + } + }, + { + "key": "fix2058", + "msg": "{repr(...)}", + "expect": { + "3.11": { + "status": "runs", + "line": "Ellipsis" + }, + "3.13": { + "status": "runs", + "line": "Ellipsis" + } + } + }, + { + "key": "row2059", + "msg": "{x:\"'<10}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'''{x:\"'<10}'''}", + "line": "Invalid format specifier '\"'<10' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'''{x:\"'<10}'''}", + "line": "Invalid format specifier '\"'<10' for object of type 'str'" + } + } + }, + { + "key": "fix2059", + "msg": "{format(x, '\"\\'<10')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Invalid format specifier '\"'<10' for object of type 'str'" + }, + "3.13": { + "status": "runs", + "line": "Invalid format specifier '\"'<10' for object of type 'str'" + } + } + }, + { + "key": "row2060", + "msg": "{x:=^10}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x:=^10}'}", + "line": "===caf\u00e9===" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x:=^10}'}", + "line": "===caf\u00e9===" + } + } + }, + { + "key": "row2061", + "msg": "{'}' + x!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "unterminated string literal (detected at line 1) (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "unterminated string literal (detected at line 1) (, line 1)" + } + } + }, + { + "key": "row2062", + "msg": "{x # note!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "'(' was never closed (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "'(' was never closed (, line 1)" + } + } + }, + { + "key": "row2063", + "msg": "{str(x!r)}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "row2064", + "msg": "{(x # c\n)!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 2)" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{(x # c\n)!r}'}", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "fix2064", + "msg": "{repr((x # c\n))}", + "expect": { + "3.11": { + "status": "runs", + "line": "'caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "'caf\u00e9'" + } + } + }, + { + "key": "row3000", + "msg": "{fr\"{d[\"a:b\"]}\"}", + "expect": { + "3.11": { + "status": "fails", + "line": "f-string: unmatched '[' (, line 1)" + }, + "3.13": { + "status": "runs", + "line": "colon-key" + } + } + }, + { + "key": "row3001", + "msg": "{rf\"{d[\"a:b\"]}\"}", + "expect": { + "3.11": { + "status": "fails", + "line": "f-string: unmatched '[' (, line 1)" + }, + "3.13": { + "status": "runs", + "line": "colon-key" + } + } + }, + { + "key": "row3002", + "msg": "{t\"{d[\"a:b\"]}\"}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax. Perhaps you forgot a comma? (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax. Perhaps you forgot a comma? (, line 1)" + } + } + }, + { + "key": "row3003", + "msg": "{u\"k\": total}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{u\"k\": total}'}", + "line": "Invalid format specifier ' total' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{u\"k\": total}'}", + "line": "Invalid format specifier ' total' for object of type 'str'" + } + } + }, + { + "key": "fix3003", + "msg": "{ {u\"k\": total} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 3.5}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 3.5}" + } + } + }, + { + "key": "row3004", + "msg": "{f'{x)}'!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "f-string: unmatched ')' (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "f-string: unmatched ')' (, line 1)" + } + } + }, + { + "key": "row3005", + "msg": "{f\"{lambda: '}'+'{'}\"!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "f-string: invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "f-string: lambda expressions are not allowed without parentheses (, line 1)" + } + } + }, + { + "key": "row3006", + "msg": "{(x]!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "closing parenthesis ']' does not match opening parenthesis '(' (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "closing parenthesis ']' does not match opening parenthesis '(' (, line 1)" + } + } + }, + { + "key": "row3007", + "msg": "{a != b!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{a != b!r}'}", + "line": "True" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{a != b!r}'}", + "line": "True" + } + } + }, + { + "key": "fix3007", + "msg": "{repr(a != b)}", + "expect": { + "3.11": { + "status": "runs", + "line": "True" + }, + "3.13": { + "status": "runs", + "line": "True" + } + } + }, + { + "key": "row3008", + "msg": "{a != b:>5}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{a != b:>5}'}", + "line": " 1" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{a != b:>5}'}", + "line": " 1" + } + } + }, + { + "key": "fix3008", + "msg": "{format(a != b, '>5')}", + "expect": { + "3.11": { + "status": "runs", + "line": " 1" + }, + "3.13": { + "status": "runs", + "line": " 1" + } + } + }, + { + "key": "row3009", + "msg": "{lambda q, /: a: v}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "fix3009-format", + "msg": "{format((lambda q, /: a), ' v')}", + "expect": { + "3.11": { + "status": "runs", + "line": "unsupported format string passed to function.__format__" + }, + "3.13": { + "status": "runs", + "line": "unsupported format string passed to function.__format__" + } + } + }, + { + "key": "fix3009-dict", + "msg": "{ {lambda q, /: a: v} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{ at 0x\u2026>: 'vv'}" + }, + "3.13": { + "status": "runs", + "line": "{ at 0x\u2026>: 'vv'}" + } + } + }, + { + "key": "row3010", + "msg": "{lambda a, b: a!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax (, line 1)" + } + } + }, + { + "key": "fix3010", + "msg": "{repr((lambda a, b: a))}", + "expect": { + "3.11": { + "status": "runs", + "line": " at 0x\u2026>" + }, + "3.13": { + "status": "runs", + "line": " at 0x\u2026>" + } + } + }, + { + "key": "row3011", + "msg": "{f\"{x:='^9}\"!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'''{f\"{x:='^9}\"!r}'''}", + "line": "Invalid format specifier '='^9' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"{x:='^9}\"!r}'}", + "line": "Invalid format specifier '='^9' for object of type 'str'" + } + } + }, + { + "key": "fix3011", + "msg": "{repr(f\"{x:='^9}\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "Invalid format specifier '='^9' for object of type 'str'" + }, + "3.13": { + "status": "runs", + "line": "Invalid format specifier '='^9' for object of type 'str'" + } + } + }, + { + "key": "row3012", + "msg": "{y := 1: v}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{y := 1: v}'}", + "line": "Invalid format specifier '= 1: v' for object of type 'int'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{y := 1: v}'}", + "line": "Invalid format specifier '= 1: v' for object of type 'int'" + } + } + }, + { + "key": "fix3012", + "msg": "{format(y := 1, ' v')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Unknown format code 'v' for object of type 'int'" + }, + "3.13": { + "status": "runs", + "line": "Unknown format code 'v' for object of type 'int'" + } + } + }, + { + "key": "row3013", + "msg": "{b\"k\": total}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{b\"k\": total}'}", + "line": "unsupported format string passed to bytes.__format__" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{b\"k\": total}'}", + "line": "unsupported format string passed to bytes.__format__" + } + } + }, + { + "key": "fix3013", + "msg": "{ {b\"k\": total} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{b'k': 3.5}" + }, + "3.13": { + "status": "runs", + "line": "{b'k': 3.5}" + } + } + }, + { + "key": "row3014", + "msg": "{\"a\" + k: v}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"a\" + k: v}'}", + "line": "Unknown format code 'v' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"a\" + k: v}'}", + "line": "Unknown format code 'v' for object of type 'str'" + } + } + }, + { + "key": "fix3014-format", + "msg": "{format(\"a\" + k, ' v')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Unknown format code 'v' for object of type 'str'" + }, + "3.13": { + "status": "runs", + "line": "Unknown format code 'v' for object of type 'str'" + } + } + }, + { + "key": "fix3014-dict", + "msg": "{ {\"a\" + k: v} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'akk': 'vv'}" + }, + "3.13": { + "status": "runs", + "line": "{'akk': 'vv'}" + } + } + }, + { + "key": "row3015", + "msg": "{1.: v}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{1.: v}'}", + "line": "Unknown format code 'v' for object of type 'float'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{1.: v}'}", + "line": "Unknown format code 'v' for object of type 'float'" + } + } + }, + { + "key": "fix3015-format", + "msg": "{format(1., ' v')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Unknown format code 'v' for object of type 'float'" + }, + "3.13": { + "status": "runs", + "line": "Unknown format code 'v' for object of type 'float'" + } + } + }, + { + "key": "fix3015-dict", + "msg": "{ {1.: v} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{1.0: 'vv'}" + }, + "3.13": { + "status": "runs", + "line": "{1.0: 'vv'}" + } + } + }, + { + "key": "row3016", + "msg": "{.5: v}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{.5: v}'}", + "line": "Unknown format code 'v' for object of type 'float'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{.5: v}'}", + "line": "Unknown format code 'v' for object of type 'float'" + } + } + }, + { + "key": "fix3016-format", + "msg": "{format(.5, ' v')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Unknown format code 'v' for object of type 'float'" + }, + "3.13": { + "status": "runs", + "line": "Unknown format code 'v' for object of type 'float'" + } + } + }, + { + "key": "fix3016-dict", + "msg": "{ {.5: v} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{0.5: 'vv'}" + }, + "3.13": { + "status": "runs", + "line": "{0.5: 'vv'}" + } + } + }, + { + "key": "row3017", + "msg": "{\"k\": x . upper()}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": x . upper()}'}", + "line": "Invalid format specifier ' x . upper()' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": x . upper()}'}", + "line": "Invalid format specifier ' x . upper()' for object of type 'str'" + } + } + }, + { + "key": "fix3017", + "msg": "{ {\"k\": x . upper()} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 'CAF\u00c9'}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 'CAF\u00c9'}" + } + } + }, + { + "key": "row3018", + "msg": "{k: v for k, v in d.items() for z in items}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{k: v for k, v in d.items() for z in items}'}", + "line": "Invalid format specifier ' v for k, v in d.items() for z in items' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{k: v for k, v in d.items() for z in items}'}", + "line": "Invalid format specifier ' v for k, v in d.items() for z in items' for object of type 'str'" + } + } + }, + { + "key": "fix3018", + "msg": "{ {k: v for k, v in d.items() for z in items} }", + "expect": { + "3.11": { + "status": "runs", + "line": "name 'items' is not defined" + }, + "3.13": { + "status": "runs", + "line": "{'a:b': 'colon-key'}" + } + } + }, + { + "key": "row3019", + "msg": "{k: v: w}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{k: v: w}'}", + "line": "Invalid format specifier ' v: w' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{k: v: w}'}", + "line": "Invalid format specifier ' v: w' for object of type 'str'" + } + } + }, + { + "key": "fix3019", + "msg": "{format(k, ' v: w')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Invalid format specifier ' v: w' for object of type 'str'" + }, + "3.13": { + "status": "runs", + "line": "Invalid format specifier ' v: w' for object of type 'str'" + } + } + }, + { + "key": "row3020", + "msg": "{\"a\": 1, : 2}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"a\": 1, : 2}'}", + "line": "Invalid format specifier ' 1, : 2' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"a\": 1, : 2}'}", + "line": "Invalid format specifier ' 1, : 2' for object of type 'str'" + } + } + }, + { + "key": "fix3020", + "msg": "{format(\"a\", ' 1, : 2')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Invalid format specifier ' 1, : 2' for object of type 'str'" + }, + "3.13": { + "status": "runs", + "line": "Invalid format specifier ' 1, : 2' for object of type 'str'" + } + } + }, + { + "key": "row3021", + "msg": "{a, k: v for k, v in d.items()}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{a, k: v for k, v in d.items()}'}", + "line": "unsupported format string passed to tuple.__format__" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{a, k: v for k, v in d.items()}'}", + "line": "unsupported format string passed to tuple.__format__" + } + } + }, + { + "key": "fix3021", + "msg": "{format((a, k), ' v for k, v in d.items()')}", + "expect": { + "3.11": { + "status": "runs", + "line": "unsupported format string passed to tuple.__format__" + }, + "3.13": { + "status": "runs", + "line": "unsupported format string passed to tuple.__format__" + } + } + }, + { + "key": "row3022", + "msg": "{total:{w}.2f}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{total:{w}.2f}'}", + "line": " 3.50" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{total:{w}.2f}'}", + "line": " 3.50" + } + } + }, + { + "key": "fix3022", + "msg": "{format(total, f'{w}.2f')}", + "expect": { + "3.11": { + "status": "runs", + "line": " 3.50" + }, + "3.13": { + "status": "runs", + "line": " 3.50" + } + } + }, + { + "key": "row3023", + "msg": "{\"k\": ...}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": ...}'}", + "line": "Format specifier missing precision" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": ...}'}", + "line": "Format specifier missing precision" + } + } + }, + { + "key": "fix3023", + "msg": "{ {\"k\": ...} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': Ellipsis}" + }, + "3.13": { + "status": "runs", + "line": "{'k': Ellipsis}" + } + } + }, + { + "key": "row3024", + "msg": "{f\"{{\" + f\"}}\" + x!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{f\"{{\" + f\"}}\" + x!r}'}", + "line": "'{}caf\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"{{\" + f\"}}\" + x!r}'}", + "line": "'{}caf\u00e9'" + } + } + }, + { + "key": "fix3024", + "msg": "{repr(f\"{{\" + f\"}}\" + x)}", + "expect": { + "3.11": { + "status": "runs", + "line": "'{}caf\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "'{}caf\u00e9'" + } + } + }, + { + "key": "row3025", + "msg": "{entr\u00e9e=}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{entr\u00e9e=}'}", + "line": "entr\u00e9e='\u00e9'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{entr\u00e9e=}'}", + "line": "entr\u00e9e='\u00e9'" + } + } + }, + { + "key": "fix3025", + "msg": "entr\u00e9e={repr(entr\u00e9e)}", + "expect": { + "3.11": { + "status": "runs", + "line": "entr\u00e9e='\u00e9'" + }, + "3.13": { + "status": "runs", + "line": "entr\u00e9e='\u00e9'" + } + } + }, + { + "key": "row3026", + "msg": "{\"k\": 1.5}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": 1.5}'}", + "line": "Space not allowed in string format specifier" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": 1.5}'}", + "line": "Space not allowed in string format specifier" + } + } + }, + { + "key": "fix3026", + "msg": "{ {\"k\": 1.5} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 1.5}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 1.5}" + } + } + }, + { + "key": "row3027", + "msg": "{\"k\": x[0].real}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": x[0].real}'}", + "line": "Invalid format specifier ' x[0].real' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": x[0].real}'}", + "line": "Invalid format specifier ' x[0].real' for object of type 'str'" + } + } + }, + { + "key": "fix3027", + "msg": "{ {\"k\": x[0].real} }", + "expect": { + "3.11": { + "status": "runs", + "line": "'str' object has no attribute 'real'" + }, + "3.13": { + "status": "runs", + "line": "'str' object has no attribute 'real'" + } + } + }, + { + "key": "row4000", + "msg": "{\"k\": 0x1f}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": 0x1f}'}", + "line": "Invalid format specifier ' 0x\u2026' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": 0x1f}'}", + "line": "Invalid format specifier ' 0x\u2026' for object of type 'str'" + } + } + }, + { + "key": "fix4000", + "msg": "{ {\"k\": 0x1f} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 31}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 31}" + } + } + }, + { + "key": "row4001", + "msg": "{\"k\": 1e3}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": 1e3}'}", + "line": "Invalid format specifier ' 1e3' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": 1e3}'}", + "line": "Invalid format specifier ' 1e3' for object of type 'str'" + } + } + }, + { + "key": "fix4001", + "msg": "{ {\"k\": 1e3} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 1000.0}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 1000.0}" + } + } + }, + { + "key": "row4002", + "msg": "{\"k\": 2j}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": 2j}'}", + "line": "Unknown format code 'j' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": 2j}'}", + "line": "Unknown format code 'j' for object of type 'str'" + } + } + }, + { + "key": "fix4002", + "msg": "{ {\"k\": 2j} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 2j}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 2j}" + } + } + }, + { + "key": "row4003", + "msg": "{\"k\": ...}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": ...}'}", + "line": "Format specifier missing precision" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": ...}'}", + "line": "Format specifier missing precision" + } + } + }, + { + "key": "fix4003", + "msg": "{ {\"k\": ...} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': Ellipsis}" + }, + "3.13": { + "status": "runs", + "line": "{'k': Ellipsis}" + } + } + }, + { + "key": "row4004", + "msg": "{\"k\": 08}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": 08}'}", + "line": "Space not allowed in string format specifier" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": 08}'}", + "line": "Space not allowed in string format specifier" + } + } + }, + { + "key": "fix4004", + "msg": "{format(\"k\", ' 08')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Space not allowed in string format specifier" + }, + "3.13": { + "status": "runs", + "line": "Space not allowed in string format specifier" + } + } + }, + { + "key": "row4005", + "msg": "{\"k\": 08.5}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": 08.5}'}", + "line": "Space not allowed in string format specifier" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": 08.5}'}", + "line": "Space not allowed in string format specifier" + } + } + }, + { + "key": "fix4005", + "msg": "{ {\"k\": 08.5} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 8.5}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 8.5}" + } + } + }, + { + "key": "row4006", + "msg": "{\"k\": .08}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": .08}'}", + "line": "Space not allowed in string format specifier" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": .08}'}", + "line": "Space not allowed in string format specifier" + } + } + }, + { + "key": "fix4006", + "msg": "{ {\"k\": .08} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 0.08}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 0.08}" + } + } + }, + { + "key": "row4007", + "msg": "{\"k\": x.5}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": x.5}'}", + "line": "Invalid format specifier ' x.5' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": x.5}'}", + "line": "Invalid format specifier ' x.5' for object of type 'str'" + } + } + }, + { + "key": "fix4007", + "msg": "{format(\"k\", ' x.5')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Invalid format specifier ' x.5' for object of type 'str'" + }, + "3.13": { + "status": "runs", + "line": "Invalid format specifier ' x.5' for object of type 'str'" + } + } + }, + { + "key": "row4008", + "msg": "{f\"\\{'\"'}\"!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "unterminated string literal (detected at line 1) (, line 1)" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"\\{'\"'}\"!r}'}", + "line": "'\\\\\"'" + } + } + }, + { + "key": "fix4008", + "msg": "{repr(f\"\\{'\"'}\")}", + "expect": { + "3.11": { + "status": "fails", + "line": "unterminated string literal (detected at line 1) (, line 1)" + }, + "3.13": { + "status": "runs", + "line": "'\\\\\"'" + } + } + }, + { + "key": "row4009", + "msg": "{f'''{f\"{{\"}}}'''!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"\"\"{f'''{f\"{{\"}}}'''!r}\"\"\"}", + "line": "'{}'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f'''{f\"{{\"}}}'''!r}'}", + "line": "'{}'" + } + } + }, + { + "key": "fix4009", + "msg": "{repr(f'''{f\"{{\"}}}''')}", + "expect": { + "3.11": { + "status": "runs", + "line": "'{}'" + }, + "3.13": { + "status": "runs", + "line": "'{}'" + } + } + }, + { + "key": "row4010", + "msg": "{f\"{x:{'}' + '{'}}\"!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'''{f\"{x:{'}' + '{'}}\"!r}'''}", + "line": "Invalid format specifier '}{' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"{x:{'}' + '{'}}\"!r}'}", + "line": "Invalid format specifier '}{' for object of type 'str'" + } + } + }, + { + "key": "fix4010", + "msg": "{repr(f\"{x:{'}' + '{'}}\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "Invalid format specifier '}{' for object of type 'str'" + }, + "3.13": { + "status": "runs", + "line": "Invalid format specifier '}{' for object of type 'str'" + } + } + }, + { + "key": "row4011", + "msg": "{\"a\" + f\"{x)}\"!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "f-string: unmatched ')' (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "f-string: unmatched ')' (, line 1)" + } + } + }, + { + "key": "row5000", + "msg": "{f\"{x:{)}}\"!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "f-string: unmatched ')' (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "f-string: unmatched ')' (, line 1)" + } + } + }, + { + "key": "row5001", + "msg": "{f\"{x:{'}'}\"}", + "expect": { + "3.11": { + "status": "fails", + "line": "f-string: expecting '}' (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "closing parenthesis ')' does not match opening parenthesis '{' (, line 1)" + } + } + }, + { + "key": "row5002", + "msg": "{\"k\": 1.}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": 1.}'}", + "line": "Format specifier missing precision" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": 1.}'}", + "line": "Format specifier missing precision" + } + } + }, + { + "key": "fix5002", + "msg": "{ {\"k\": 1.} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 1.0}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 1.0}" + } + } + }, + { + "key": "row6000", + "msg": "{\"k\": 1.e3}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": 1.e3}'}", + "line": "Format specifier missing precision" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": 1.e3}'}", + "line": "Format specifier missing precision" + } + } + }, + { + "key": "fix6000", + "msg": "{ {\"k\": 1.e3} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 1000.0}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 1000.0}" + } + } + }, + { + "key": "row6001", + "msg": "{\"k\": 1.5.real}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": 1.5.real}'}", + "line": "Invalid format specifier ' 1.5.real' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": 1.5.real}'}", + "line": "Invalid format specifier ' 1.5.real' for object of type 'str'" + } + } + }, + { + "key": "fix6001", + "msg": "{ {\"k\": 1.5.real} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 1.5}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 1.5}" + } + } + }, + { + "key": "row6002", + "msg": "{\"k\": 1..real}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": 1..real}'}", + "line": "Format specifier missing precision" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": 1..real}'}", + "line": "Format specifier missing precision" + } + } + }, + { + "key": "fix6002", + "msg": "{ {\"k\": 1..real} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 1.0}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 1.0}" + } + } + }, + { + "key": "row6003", + "msg": "{\"k\": 1.real}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": 1.real}'}", + "line": "Format specifier missing precision" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": 1.real}'}", + "line": "Format specifier missing precision" + } + } + }, + { + "key": "fix6003", + "msg": "{format(\"k\", ' 1.real')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Format specifier missing precision" + }, + "3.13": { + "status": "runs", + "line": "Format specifier missing precision" + } + } + }, + { + "key": "row6004", + "msg": "{\"k\": 1 .real}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": 1 .real}'}", + "line": "Invalid format specifier ' 1 .real' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": 1 .real}'}", + "line": "Invalid format specifier ' 1 .real' for object of type 'str'" + } + } + }, + { + "key": "fix6004", + "msg": "{ {\"k\": 1 .real} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 1}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 1}" + } + } + }, + { + "key": "row6005", + "msg": "{\"k\": x1.real}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": x1.real}'}", + "line": "Invalid format specifier ' x1.real' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": x1.real}'}", + "line": "Invalid format specifier ' x1.real' for object of type 'str'" + } + } + }, + { + "key": "fix6005", + "msg": "{ {\"k\": x1.real} }", + "expect": { + "3.11": { + "status": "runs", + "line": "name 'x1' is not defined" + }, + "3.13": { + "status": "runs", + "line": "name 'x1' is not defined" + } + } + }, + { + "key": "row6006", + "msg": "{\"k\": 2j.real}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": 2j.real}'}", + "line": "Invalid format specifier ' 2j.real' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": 2j.real}'}", + "line": "Invalid format specifier ' 2j.real' for object of type 'str'" + } + } + }, + { + "key": "fix6006", + "msg": "{ {\"k\": 2j.real} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 0.0}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 0.0}" + } + } + }, + { + "key": "row6007", + "msg": "{\"k\": 0x1f.real}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": 0x1f.real}'}", + "line": "Invalid format specifier ' 0x\u2026.real' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"k\": 0x1f.real}'}", + "line": "Invalid format specifier ' 0x\u2026.real' for object of type 'str'" + } + } + }, + { + "key": "fix6007", + "msg": "{ {\"k\": 0x1f.real} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'k': 31}" + }, + "3.13": { + "status": "runs", + "line": "{'k': 31}" + } + } + }, + { + "key": "row7000", + "msg": "{k: v, j: w}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{k: v, j: w}'}", + "line": "Invalid format specifier ' v, j: w' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{k: v, j: w}'}", + "line": "Invalid format specifier ' v, j: w' for object of type 'str'" + } + } + }, + { + "key": "fix7000", + "msg": "{ {k: v, j: w} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'kk': 'vv', 'jj': 10}" + }, + "3.13": { + "status": "runs", + "line": "{'kk': 'vv', 'jj': 10}" + } + } + }, + { + "key": "row7001", + "msg": "{k:v,j:w}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{k:v,j:w}'}", + "line": "Invalid format specifier 'v,j:w' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{k:v,j:w}'}", + "line": "Invalid format specifier 'v,j:w' for object of type 'str'" + } + } + }, + { + "key": "fix7001", + "msg": "{ {k:v,j:w} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'kk': 'vv', 'jj': 10}" + }, + "3.13": { + "status": "runs", + "line": "{'kk': 'vv', 'jj': 10}" + } + } + }, + { + "key": "row7002", + "msg": "{f\"{d[\"a:b\"]}\": total}", + "expect": { + "3.11": { + "status": "fails", + "line": "f-string: unmatched '[' (, line 1)" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{f\"{d[\"a:b\"]}\": total}'}", + "line": "Invalid format specifier ' total' for object of type 'str'" + } + } + }, + { + "key": "fix7002", + "msg": "{ {f\"{d[\"a:b\"]}\": total} }", + "expect": { + "3.11": { + "status": "fails", + "line": "f-string: unmatched '[' (, line 1)" + }, + "3.13": { + "status": "runs", + "line": "{'colon-key': 3.5}" + } + } + }, + { + "key": "row7003", + "msg": "{t\"{d[\"a:b\"]}\": total}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax. Perhaps you forgot a comma? (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax. Perhaps you forgot a comma? (, line 1)" + } + } + }, + { + "key": "fix7003", + "msg": "{ {t\"{d[\"a:b\"]}\": total} }", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax. Perhaps you forgot a comma? (, line 1)" + }, + "3.13": { + "status": "fails", + "line": "invalid syntax. Perhaps you forgot a comma? (, line 1)" + } + } + }, + { + "key": "row7004", + "msg": "{k: v for k in d}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{k: v for k in d}'}", + "line": "Invalid format specifier ' v for k in d' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{k: v for k in d}'}", + "line": "Invalid format specifier ' v for k in d' for object of type 'str'" + } + } + }, + { + "key": "fix7004-format", + "msg": "{format(k, ' v for k in d')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Invalid format specifier ' v for k in d' for object of type 'str'" + }, + "3.13": { + "status": "runs", + "line": "Invalid format specifier ' v for k in d' for object of type 'str'" + } + } + }, + { + "key": "fix7004-dict", + "msg": "{ {k: v for k in d} }", + "expect": { + "3.11": { + "status": "runs", + "line": "name 'v' is not defined" + }, + "3.13": { + "status": "runs", + "line": "{'a:b': 'vv'}" + } + } + }, + { + "key": "row7005", + "msg": "{k:v}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{k:v}'}", + "line": "Unknown format code 'v' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{k:v}'}", + "line": "Unknown format code 'v' for object of type 'str'" + } + } + }, + { + "key": "fix7005", + "msg": "{format(k, 'v')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Unknown format code 'v' for object of type 'str'" + }, + "3.13": { + "status": "runs", + "line": "Unknown format code 'v' for object of type 'str'" + } + } + }, + { + "key": "row7006", + "msg": "{1:'a'}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"{1:'a'}\"}", + "line": "Invalid format specifier ''a'' for object of type 'int'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f\"{1:'a'}\"}", + "line": "Invalid format specifier ''a'' for object of type 'int'" + } + } + }, + { + "key": "fix7006", + "msg": "{format(1, \"'a'\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "Invalid format specifier ''a'' for object of type 'int'" + }, + "3.13": { + "status": "runs", + "line": "Invalid format specifier ''a'' for object of type 'int'" + } + } + }, + { + "key": "row7007", + "msg": "{x:d}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x:d}'}", + "line": "Unknown format code 'd' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x:d}'}", + "line": "Unknown format code 'd' for object of type 'str'" + } + } + }, + { + "key": "fix7007", + "msg": "{format(x, 'd')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Unknown format code 'd' for object of type 'str'" + }, + "3.13": { + "status": "runs", + "line": "Unknown format code 'd' for object of type 'str'" + } + } + }, + { + "key": "row7008", + "msg": "{x: 10}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x: 10}'}", + "line": "Space not allowed in string format specifier" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x: 10}'}", + "line": "Space not allowed in string format specifier" + } + } + }, + { + "key": "fix7008-format", + "msg": "{format(x, ' 10')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Space not allowed in string format specifier" + }, + "3.13": { + "status": "runs", + "line": "Space not allowed in string format specifier" + } + } + }, + { + "key": "fix7008-dict", + "msg": "{ {x: 10} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'caf\u00e9': 10}" + }, + "3.13": { + "status": "runs", + "line": "{'caf\u00e9': 10}" + } + } + }, + { + "key": "row7009", + "msg": "{k:\tv}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{k:\tv}'}", + "line": "Invalid format specifier '\tv' for object of type 'str'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{k:\tv}'}", + "line": "Invalid format specifier '\tv' for object of type 'str'" + } + } + }, + { + "key": "fix7009-format", + "msg": "{format(k, '\\tv')}", + "expect": { + "3.11": { + "status": "runs", + "line": "Invalid format specifier '\tv' for object of type 'str'" + }, + "3.13": { + "status": "runs", + "line": "Invalid format specifier '\tv' for object of type 'str'" + } + } + }, + { + "key": "fix7009-dict", + "msg": "{ {k:\tv} }", + "expect": { + "3.11": { + "status": "runs", + "line": "{'kk': 'vv'}" + }, + "3.13": { + "status": "runs", + "line": "{'kk': 'vv'}" + } + } + }, + { + "key": "row7010", + "msg": "{x: >10}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{x: >10}'}", + "line": " caf\u00e9" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{x: >10}'}", + "line": " caf\u00e9" + } + } + }, + { + "key": "fix7010", + "msg": "{format(x, ' >10')}", + "expect": { + "3.11": { + "status": "runs", + "line": " caf\u00e9" + }, + "3.13": { + "status": "runs", + "line": " caf\u00e9" + } + } + } + ] +} \ No newline at end of file diff --git a/tests/adapters/python/integration/logpoint-interpreters.ts b/tests/adapters/python/integration/logpoint-interpreters.ts new file mode 100644 index 000000000..daca3b5ce --- /dev/null +++ b/tests/adapters/python/integration/logpoint-interpreters.ts @@ -0,0 +1,49 @@ +/** + * The interpreters the logpoint corpus runs on (issues #1334, #1349). + * + * `MCP_LOGPOINT_PYTHONS` names them: Python executables separated by the + * platform's path delimiter (`;` on Windows, `:` elsewhere). Unset, the corpus + * runs on the one interpreter the Python suite already uses — `PYTHON_PATH`, + * else `python` on Windows and `python3` elsewhere — so CI's existing job + * covers its Python with no change to it, and a second workflow names another. + */ +import path from 'node:path'; +import { spawnSync } from 'node:child_process'; + +export interface InterpreterUnderTest { + /** The executable as named. */ + command: string; + /** `3.13.12`, or undefined when it does not run or has no debugpy. */ + version?: string; + debugpy?: string; + /** Its `sys.executable`: an absolute path, where `command` may be a bare name a child would resolve elsewhere. */ + executable?: string; +} + +function probe(command: string): InterpreterUnderTest { + try { + const result = spawnSync( + command, + ['-c', 'import sys, debugpy; print(sys.version.split()[0], debugpy.__version__); print(sys.executable)'], + { encoding: 'utf8', timeout: 30_000, windowsHide: true } + ); + const [first = '', executable] = (result.status === 0 ? result.stdout.trim() : '').split(/\r?\n/); + const [version, debugpy] = first.split(/\s+/); + return version && debugpy ? { command, version, debugpy, ...(executable ? { executable: executable.trim() } : {}) } : { command }; + } catch { + return { command }; + } +} + +export function interpretersUnderTest(): InterpreterUnderTest[] { + const named = process.env.MCP_LOGPOINT_PYTHONS?.split(path.delimiter).map((entry) => entry.trim()).filter(Boolean); + const commands = named && named.length > 0 + ? named + : [process.env.PYTHON_PATH || (process.platform === 'win32' ? 'python' : 'python3')]; + return commands.map(probe); +} + +/** `3.13` for `3.13.12`: the key the recorded expectations are kept under. */ +export function minorOf(version: string): string { + return version.split('.').slice(0, 2).join('.'); +} diff --git a/tests/adapters/python/integration/python-logpoint-corpus.test.ts b/tests/adapters/python/integration/python-logpoint-corpus.test.ts new file mode 100644 index 000000000..229dd7b08 --- /dev/null +++ b/tests/adapters/python/integration/python-logpoint-corpus.test.ts @@ -0,0 +1,196 @@ +/** + * The Python logpoint check, row by row, on real debugpy (issues #1334, #1349). + * + * The checker the policy ships (PYTHON_LOGPOINT_CHECKER_SOURCE) is run in each + * interpreter under test against pydevd's own hit on real frames + * (logpoint-corpus/emulate.py). What is asserted, per interpreter: + * + * - every counterexample of the design's reviews (corpus.json): the verdict, the + * wire, and what the message as written and as sent log in each value + * environment, against what was recorded for that interpreter; + * - every row of the 562-row table (table.json): the verdict and the wire; + * - the everyday messages, the %-directive x group combinations and the fuzz + * sets: no message that runs as written in either value environment has its + * wire changed — not one; + * - three rows stated here: a rewritten group's own % is not doubled, a + * starred group's element count is left to the hit, a message past the + * length bound is not checked; + * - a failure of the checker itself (its recursion limit) is never a verdict: + * the message goes as written; + * - the bounds: the worst message the digit and width bounds allow peaks under + * 4 MB and 1 s, and the review's 28.6 MB message is declined. + * + * The expectations are recorded per Python minor version (the f-string grammar + * changed in 3.12); an interpreter with none recorded fails here rather than + * passing on the invariants alone. MCP_LOGPOINT_PYTHONS names the interpreters + * (see logpoint-interpreters.ts). + */ +import { afterAll, beforeAll, describe, expect, it } from 'vitest'; +import fs from 'node:fs'; +import os from 'node:os'; +import path from 'node:path'; +import { spawnSync } from 'node:child_process'; +import { fileURLToPath } from 'node:url'; +import { PYTHON_LOGPOINT_CHECKER_SOURCE } from '@debugmcp/shared'; +import { interpretersUnderTest, minorOf, type InterpreterUnderTest } from './logpoint-interpreters.js'; + +const here = path.dirname(fileURLToPath(import.meta.url)); +const DATA = path.join(here, 'logpoint-corpus'); +const named = Boolean(process.env.MCP_LOGPOINT_PYTHONS); +const interpreters = interpretersUnderTest(); +const runnable = interpreters.filter((i) => i.version !== undefined); + +interface Expectation { + status: string; + wire?: string; + assigns?: string[]; + envs?: Record; assignedSent?: Record }>; + line?: string | null; +} +interface CorpusRow { id: string; msg: string; expect: Record } +interface TableRow { key: string; msg: string; expect: Record } +interface Verdict { status: string; wire?: string; assigns?: string[] } +interface Emulated { + error?: string; + python: string; + debugpy: string; + seconds: number; + corpus: Array<{ id: string; verdict: Verdict; envs: Record; assignedSent?: Record }> }>; + table: Array<{ key: string; verdict: Verdict }>; + generated: Record; + resource: Array<{ len: number; verdict: Verdict }>; + bounds: Record; + extra: Array<{ status: string; wire: string | null; logA: string | null }>; +} + +const corpus = (JSON.parse(fs.readFileSync(path.join(DATA, 'corpus.json'), 'utf8')) as { rows: CorpusRow[] }).rows; +const table = (JSON.parse(fs.readFileSync(path.join(DATA, 'table.json'), 'utf8')) as { rows: TableRow[] }).rows; + +let scratch: string; + +beforeAll(() => { + scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'mcp-logpoint-corpus-')); + fs.writeFileSync(path.join(scratch, 'checker.py'), PYTHON_LOGPOINT_CHECKER_SOURCE, 'utf8'); +}); + +afterAll(() => { + if (scratch) fs.rmSync(scratch, { recursive: true, force: true }); +}); + +function emulate(interpreter: InterpreterUnderTest): Emulated { + const out = path.join(scratch, `emulated-${process.pid}-${Math.random().toString(36).slice(2)}.json`); + const run = spawnSync( + interpreter.command, + // -B: no bytecode written beside the committed generator. + ['-B', '-X', 'utf8', path.join(DATA, 'emulate.py'), path.join(scratch, 'checker.py'), out], + { encoding: 'utf8', timeout: 900_000, windowsHide: true, maxBuffer: 16 * 1024 * 1024 } + ); + if (run.status !== 0) { + throw new Error(`emulate.py failed on ${interpreter.command} (status ${run.status}): ${run.stderr.slice(-2000)}`); + } + return JSON.parse(fs.readFileSync(out, 'utf8')) as Emulated; +} + +describe('Python logpoint corpus: the interpreters are the ones named @requires-python', () => { + it.skipIf(!named)('every interpreter MCP_LOGPOINT_PYTHONS names runs and has debugpy', () => { + expect(interpreters.filter((i) => i.version === undefined).map((i) => i.command)).toEqual([]); + }); +}); + +describe.skipIf(runnable.length === 0)('Python logpoint corpus, emulated on real debugpy @requires-python', () => { + describe.each(runnable.map((i) => [`${i.version} (debugpy ${i.debugpy})`, i] as const))('on Python %s', (_label, interpreter) => { + let result: Emulated; + const minor = minorOf(interpreter.version!); + + beforeAll(() => { + result = emulate(interpreter); + console.log(`[logpoint corpus] Python ${result.python}, debugpy ${result.debugpy}: emulated in ${result.seconds} s`); + }, 900_000); + + it('has expectations recorded for this interpreter', () => { + expect(result.error).toBeUndefined(); + expect(Object.keys(corpus[0].expect), `no expectations recorded for Python ${minor}`).toContain(minor); + }); + + it('gives every counterexample its recorded verdict, wire and logs, row by row', () => { + const mismatches: unknown[] = []; + corpus.forEach((row, index) => { + const want = row.expect[minor]; + const got = result.corpus[index]; + if (!want || got?.id !== row.id) { + mismatches.push({ id: row.id, problem: 'no expectation or out of order' }); + return; + } + const wire = got.verdict.wire ?? undefined; + if (got.verdict.status !== want.status || wire !== want.wire || JSON.stringify(got.verdict.assigns ?? null) !== JSON.stringify(want.assigns ?? null)) { + mismatches.push({ id: row.id, want: { status: want.status, wire: want.wire, assigns: want.assigns }, got: got.verdict }); + } + for (const [env, expected] of Object.entries(want.envs ?? {})) { + const observed = got.envs[env]; + if (JSON.stringify(observed ?? null) !== JSON.stringify(expected)) { + mismatches.push({ id: row.id, env, want: expected, got: observed }); + } + } + }); + expect(mismatches).toEqual([]); + }); + + it('gives every row of the 562-row table its recorded verdict and wire', () => { + const mismatches: unknown[] = []; + table.forEach((row, index) => { + const want = row.expect[minor]; + const got = result.table[index]; + if (!want || got?.key !== row.key) { + mismatches.push({ key: row.key, problem: 'no expectation or out of order' }); + return; + } + if (got.verdict.status !== want.status || (got.verdict.wire ?? undefined) !== want.wire) { + mismatches.push({ key: row.key, msg: row.msg, want: { status: want.status, wire: want.wire }, got: got.verdict }); + } + }); + expect(mismatches).toEqual([]); + }); + + it('never changes the wire of a message that runs as written (generated sets, the table)', () => { + const changed = Object.entries(result.generated) + .filter(([, set]) => set.wireChanged > 0) + .map(([name, set]) => ({ name, wireChanged: set.wireChanged, examples: set.examples })); + expect(changed).toEqual([]); + for (const [name, set] of Object.entries(result.generated)) { + // Each set reached its size and has messages that run: the assertion above is about something. + expect(set.messages, name).toBeGreaterThan(0); + expect(set.worksAsWritten, name).toBeGreaterThan(0); + } + console.log( + `[logpoint corpus] Python ${result.python}: messages that run as written, wire unchanged: ` + + Object.entries(result.generated).map(([name, set]) => `${name} ${set.worksAsWritten}/${set.messages}`).join(', ') + ); + }); + + it("doubles only the text's %, never a group's own; leaves a starred count to the hit; does not check past the length bound", () => { + expect(result.extra).toEqual([ + { status: 'rewritten', wire: "100%% {f'{total:.1%}'}", logA: '100% 350.0%' }, + { status: 'runs', wire: null, logA: '10 20 30 40' }, + { status: 'unchecked', wire: null, logA: 'invalid syntax (, line 1)' } + ]); + }); + + it('never takes a failure of the checker itself for a verdict', () => { + for (const { verdict } of result.resource) { + expect(['runs', 'unchecked']).toContain(verdict.status); + expect(verdict.wire).toBeUndefined(); + } + }); + + it('bounds the formatting before it happens: memory and time of the worst messages', () => { + const review = result.bounds['review: an emoji, 511 x %9999s, 512 fields']; + expect(review.status).toBe('unchecked'); + expect(review.wireChanged).toBe(false); + for (const [name, bound] of Object.entries(result.bounds)) { + expect(bound.peakBytes, name).toBeLessThan(4 * 1024 * 1024); + expect(bound.ms, name).toBeLessThan(1000); + } + console.log(`[logpoint corpus] Python ${result.python} bounds: ${JSON.stringify(result.bounds)}`); + }); + }); +}); diff --git a/tests/adapters/python/integration/python-logpoint-live.test.ts b/tests/adapters/python/integration/python-logpoint-live.test.ts new file mode 100644 index 000000000..68e743048 --- /dev/null +++ b/tests/adapters/python/integration/python-logpoint-live.test.ts @@ -0,0 +1,204 @@ +/** + * The 562-row live table and the counterexample corpus as real logpoints, + * through the built server, on real debugpy (issues #1334, #1349). + * + * Every message is set as the caller wrote it, before the launch; the launch's + * check decides what goes to debugpy. Per row, against what was recorded for + * the interpreter: the message the adapter received (`logMessageSent` in + * list_breakpoints, or the message itself), the line the program logged, and, + * for the corpus rows, the locals a hit changed. A message that runs as + * written is sent unchanged and adds nothing to the launch answer; one that + * was rewritten is listed there with what was sent. + * + * One launch per interpreter (MCP_LOGPOINT_PYTHONS, see + * logpoint-interpreters.ts): the fixture is generated with one function per + * logpoint, each with fresh locals, called in order. + */ +import { afterEach, describe, expect, it } from 'vitest'; +import fs from 'node:fs'; +import os from 'node:os'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { startStdioClient, type StdioClientHandle, type ToolAnswer } from '../../../test-utils/helpers/mcp-stdio-client.js'; +import { interpretersUnderTest, minorOf } from './logpoint-interpreters.js'; + +const here = path.dirname(fileURLToPath(import.meta.url)); +const DATA = path.join(here, 'logpoint-corpus'); +const runnable = interpretersUnderTest().filter((i) => i.version !== undefined); + +interface LiveExpect { asWritten: string | null; sent?: string | null; assignedAsWritten?: Record; assignedSent?: Record } +interface Expectation { status: string; wire?: string; line?: string | null; assigns?: string[]; live?: LiveExpect } +interface Row { key?: string; id?: string; msg: string; expect: Record } + +const table = (JSON.parse(fs.readFileSync(path.join(DATA, 'table.json'), 'utf8')) as { rows: Row[] }).rows; +const corpus = (JSON.parse(fs.readFileSync(path.join(DATA, 'corpus.json'), 'utf8')) as { rows: Row[] }).rows; + +/** The 562-row table's locals (#1346's gen_fixture.py), the ones its lines were recorded with. */ +const TABLE_HEADER = [ + 'import datetime', 'import json', 'import os', 'import re', 'import time', '', '', + 'class Matrix:', ' def __getitem__(self, key):', ' return "M[%r]" % (key,)', '', '', + 'def _vals():', + " return ('café', 3.5, [10, 20, 30, 40], {'a:b': 'colon-key'}, 'old', 1, 2, 10, {'a': 8}, 2, 255,", + " datetime.datetime(2026, 11, 28, 13, 45, 7), re.match('(a)b', 'ab'), 'C', 'kk', 'vv', [('p', 1)],", + " Matrix(), len, True, 1, (lambda *aa: aa), object, 'é', 'L', 3, 5, 0, 7, 9, 8, 'jj', ['m'])", + '', '', 'AFTER = {}', '' +]; +const TABLE_LOCALS = + ' x, total, items, d, entry, a, b, w, wd, prec, n, dt, match, case, k, v, pairs, matrix, fn, ready, ' + + 'i, f, obj, entrée, land, minor, literal, y, c, q, p, j, matches = _vals()'; +/** The corpus's environment A (its live lines were recorded with these). */ +const CORPUS_LOCALS = + " x, total, items, i, n, ch, w, y, step, a, b, entry, d, literal, entrée, s = 'café', 3.5, [10, 20, 30, 40], 3, 255, " + + "'A', 8, 7, 0, 1, 2, 'old', {'a:b': 'colon-key', '}': 'brace', 'k': 1}, 5, 'é', 'str'"; +const CORPUS_NAMES = 'x total items i n ch w y step a b entry d literal entrée s'.split(' '); +/** The locals whose change a corpus row records (the recorded run compared these three). */ +const TRACKED: Record = { step: '0', y: '7', x: "'café'" }; + +interface Case { + key: string; + msg: string; + line: number; + wire: string; + status: string; + /** The lines the hit logs: none when debugpy logs nothing. */ + lines: string[]; + assigned?: Record; +} + +function fixtureFor(minor: string, dir: string): { file: string; cases: Case[] } { + const lines = [...TABLE_HEADER]; + const cases: Case[] = []; + // One function per logpoint; the logpoint is on the function's last line before `return 0` + // when `before` is set, else on `return 0` itself. + const add = (key: string, msg: string, want: Expectation, logged: string | null | undefined, + assigned: Record | undefined, body: string[], before?: string) => { + lines.push(`def c${cases.length}():`, ...body); + if (before !== undefined) { + lines.push(before); + } else { + lines.push(' return 0'); + } + cases.push({ + key, msg, line: lines.length, wire: want.wire ?? msg, status: want.status, + lines: logged === null || logged === undefined ? [] : logged.split('\n'), + ...(assigned ? { assigned } : {}) + }); + if (before !== undefined) { + lines.push(' return 0'); + } + lines.push(''); + }; + for (const row of table) { + const want = row.expect[minor]; + add(`table:${row.key}`, row.msg, want, want.line, undefined, [TABLE_LOCALS]); + } + for (const row of corpus) { + const want = row.expect[minor]; + if (!want?.live) continue; + const key = `corpus:${row.id}`; + const rewritten = want.wire !== undefined; + // The logpoint sits on the AFTER line: the hit runs first, so the line records what it changed. + add(key, row.msg, want, rewritten ? want.live.sent : want.live.asWritten, + rewritten ? want.live.assignedSent : want.live.assignedAsWritten, + [CORPUS_LOCALS], ` AFTER['${key}'] = {${CORPUS_NAMES.map((n) => `'${n}': repr(${n})`).join(', ')}}`); + } + lines.push('', "if __name__ == '__main__':", ...cases.map((_, k) => ` c${k}()`), + " json.dump(AFTER, open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'locals-after.json'), 'w', encoding='utf-8'), ensure_ascii=True)", + // debugpy drops logpoint lines still queued at exit (#1265). + ' time.sleep(1)', ''); + const file = path.join(dir, 'live_logpoints.py'); + fs.writeFileSync(file, lines.join('\n'), 'utf8'); + return { file, cases }; +} + +type OutputAnswer = ToolAnswer & { entries?: Array<{ category: string; output: string }>; hasMore?: boolean; nextSince?: number }; +type ListAnswer = ToolAnswer & { breakpoints: Array<{ line: number; logMessage?: string; logMessageSent?: string; logMessageCheck?: string }> }; +type LaunchAnswer = ToolAnswer & { data?: { logMessageChecks?: Array<{ line: number; logMessage: string; logMessageSent?: string; status: string }> } }; + +const normalize = (text: string): string => text.replace(/0x[0-9A-Fa-f]+/g, '0x…'); + +describe.skipIf(runnable.length === 0)('Python logpoints live through the server, row by row @requires-python', () => { + let server: StdioClientHandle | undefined; + let scratch: string | undefined; + + afterEach(async () => { + await server?.close(); + server = undefined; + if (scratch) fs.rmSync(scratch, { recursive: true, force: true }); + scratch = undefined; + }); + + it.each(runnable.map((i) => [`${i.version} (debugpy ${i.debugpy})`, i] as const))( + 'on Python %s: what was sent and what was logged, per row', + async (_label, interpreter) => { + const minor = minorOf(interpreter.version!); + expect(Object.keys(table[0].expect), `no expectations recorded for Python ${minor}`).toContain(minor); + scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'mcp-logpoint-live-')); + const { file, cases } = fixtureFor(minor, scratch); + + server = await startStdioClient({ name: 'python-logpoint-live', env: { PYTHON_PATH: interpreter.command }, callTimeoutMs: 300_000 }); + await server.createSession('python', 'python-logpoint-live'); + const started0 = Date.now(); + for (const c of cases) { + const set = await server.call('set_breakpoint', { file, line: c.line, logMessage: c.msg }); + expect(set.success, JSON.stringify(set)).toBe(true); + // Before the launch nothing is checked: the answer adds nothing. + expect(set.logMessageSent, c.key).toBeUndefined(); + expect(set.logMessageCheck, c.key).toBeUndefined(); + } + const launch = await server.call('start_debugging', { scriptPath: file }); + expect(launch.success, JSON.stringify(launch).slice(0, 2000)).toBe(true); + if (launch.state !== 'stopped') { + const ended = await server.call('wait_for_stop', { timeout: 240_000 }); + expect(ended.state).toBe('stopped'); + } + const entries: Array<{ category: string; output: string }> = []; + let since = 0; + for (let page = 0; page < 200; page++) { + const out = await server.call('get_output', { since, limit: 1000 }); + entries.push(...(out.entries ?? [])); + if ((out.entries ?? []).length === 0 || out.hasMore !== true) break; + since = out.nextSince!; + } + const listed = await server.call('list_breakpoints'); + const byLine = new Map(listed.breakpoints.map((bp) => [bp.line, bp])); + const checks = new Map((launch.data?.logMessageChecks ?? []).map((note) => [note.line, note])); + const after = JSON.parse(fs.readFileSync(path.join(scratch, 'locals-after.json'), 'utf8')) as Record>; + const logged = entries.filter((e) => e.category === 'stdout').map((e) => e.output).join('').split(/\r?\n/); + console.log(`[logpoint live] Python ${interpreter.version}: ${cases.length} logpoints, ${Math.round((Date.now() - started0) / 1000)} s from the first set to the last line`); + + const mismatches: unknown[] = []; + let cursor = 0; + for (const c of cases) { + const bp = byLine.get(c.line); + const sent = bp?.logMessageSent ?? bp?.logMessage; + const live = logged.slice(cursor, cursor + c.lines.length).map(normalize); + cursor += c.lines.length; + if (bp?.logMessage !== c.msg || sent !== c.wire) { + mismatches.push({ key: c.key, problem: 'sent', want: c.wire, got: sent }); + } + if (JSON.stringify(live) !== JSON.stringify(c.lines.map(normalize))) { + mismatches.push({ key: c.key, problem: 'logged', want: c.lines, got: live }); + } + // The launch answer lists a rewrite with what was sent, and never a message that runs without assigning. + const note = checks.get(c.line); + if (c.wire !== c.msg && note?.logMessageSent !== c.wire) { + mismatches.push({ key: c.key, problem: 'launch answer', want: c.wire, got: note }); + } + if (c.status === 'runs' && c.wire === c.msg && note !== undefined && note.status !== 'runs') { + mismatches.push({ key: c.key, problem: 'launch answer lists a message that runs', got: note }); + } + if (c.key.startsWith('corpus:')) { + const locals = after[c.key] ?? {}; + const changed = Object.fromEntries(Object.entries(locals).filter(([k, v]) => TRACKED[k] !== undefined && TRACKED[k] !== v)); + if (JSON.stringify(changed) !== JSON.stringify(c.assigned ?? {})) { + mismatches.push({ key: c.key, problem: 'assigned', want: c.assigned ?? {}, got: changed }); + } + } + } + expect(mismatches).toEqual([]); + expect(logged.slice(cursor).filter(Boolean), 'lines no logpoint accounts for').toEqual([]); + }, + 600_000 + ); +}); diff --git a/tests/adapters/python/integration/python-logpoint-paths.test.ts b/tests/adapters/python/integration/python-logpoint-paths.test.ts new file mode 100644 index 000000000..02f3b3339 --- /dev/null +++ b/tests/adapters/python/integration/python-logpoint-paths.test.ts @@ -0,0 +1,355 @@ +/** + * Where a checked logpoint goes, on real debugpy (issues #1334, #1349). + * + * The DAP trace of the worker (DAP_TRACE_FILE) is read for every + * setBreakpoints request that reached the adapter. Asserted: + * + * - the four paths a stored logpoint leaves by carry the wire to the adapter: + * the launch's initial set, a live set and the re-sends of its file, a child + * session's adoption, and a restart — which checks again with a new checker; + * - a message that runs is sent as written and adds nothing to any answer; + * - not checked, and sent as written, with the reason in the answer: a launch + * that names its own interpreter (`python`, `pythonPath`), an attach (before + * and after it), and a child on another interpreter (when one is named); + * - the checker ends with its run, is gone when close_debug_session returns, + * and ends by itself when the process that owns it is killed outright. + */ +import { afterEach, describe, expect, it } from 'vitest'; +import fs from 'node:fs'; +import net from 'node:net'; +import os from 'node:os'; +import path from 'node:path'; +import { spawn, spawnSync, type ChildProcess } from 'node:child_process'; +import { fileURLToPath } from 'node:url'; +import { PYTHON_LOGPOINT_CHECKER } from '@debugmcp/shared'; +import { startStdioClient, type StdioClientHandle, type ToolAnswer } from '../../../test-utils/helpers/mcp-stdio-client.js'; +import { interpretersUnderTest } from './logpoint-interpreters.js'; + +const interpreters = interpretersUnderTest().filter((i) => i.version !== undefined); +const python = interpreters[0]; +const other = interpreters.find((i) => i.version !== python?.version); +const WIRE = "{f'{x!r}'}"; + +const FIXTURE = [ + 'import os, subprocess, sys, time', + '', + '', + 'def work():', + ' x = "café"', + ' step = 0', + ' step += 1 # LP_A', + ' step += 1 # LP_B', + ' return step', + '', + '', + 'def main():', + ' mode = sys.argv[1] if len(sys.argv) > 1 else "plain"', + ' if mode == "wait":', + ' deadline = time.time() + 60', + ' while not os.path.exists(sys.argv[2]) and time.time() < deadline:', + ' time.sleep(0.05)', + ' work()', + ' if mode == "child":', + ' subprocess.run([sys.argv[2] if len(sys.argv) > 2 else sys.executable, os.path.abspath(__file__), "plain"], check=True)', + ' time.sleep(0.5)', + '', + '', + 'if __name__ == "__main__":', + ' main()', + '' +].join('\n'); +const LP_A = 7; +const LP_B = 8; + +type Answer = ToolAnswer & Record & { + data?: { logMessageChecks?: Array<{ line: number; logMessage: string; logMessageSent?: string; status: string; logMessageCheck: string }> }; +}; + +/** The setBreakpoints requests the worker sent, per connection, with the messages they carried. */ +function sentLogMessages(trace: string, file: string): Array<{ conn: string; messages: Array }> { + if (!fs.existsSync(trace)) return []; + return fs.readFileSync(trace, 'utf8').split('\n').filter(Boolean) + .map((line) => JSON.parse(line) as { conn: string; direction?: string; payload?: { type?: string; command?: string; arguments?: { source?: { path?: string }; breakpoints?: Array<{ logMessage?: string }> } } }) + .filter((r) => r.direction === 'out' && r.payload?.type === 'request' && r.payload.command === 'setBreakpoints' && + path.resolve(r.payload.arguments?.source?.path ?? '').toLowerCase() === path.resolve(file).toLowerCase()) + .map((r) => ({ conn: r.conn, messages: (r.payload!.arguments!.breakpoints ?? []).map((bp) => bp.logMessage) })); +} + +/** Where startStdioClient's servers log: `--