diff --git a/.github/workflows/python-logpoint-corpus.yml b/.github/workflows/python-logpoint-corpus.yml new file mode 100644 index 000000000..1de2cec1d --- /dev/null +++ b/.github/workflows/python-logpoint-corpus.yml @@ -0,0 +1,92 @@ +name: Python logpoint corpus + +# The Python logpoint check (issues #1334, #1349) on both sides 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.12 and 3.13: the +# properties of the check against the interpreter itself, the pins recorded for +# its minor version (named here, so an interpreter with none fails), and the +# process-settings counterexamples, live. Pull requests that touch the check or +# what the live tests go through, 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/shared/src/models/**' + - 'packages/adapter-python/src/**' + - 'src/server.ts' + - 'src/server/handlers/breakpoint-tools.ts' + - 'src/server/handlers/shared.ts' + - 'src/session/launch/debug-launcher.ts' + - 'src/session/attach/attach-controller.ts' + - '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/logpoint-pins.ts' + - 'tests/adapters/python/integration/python-logpoint-*.test.ts' + - 'tests/adapters/python/integration/logpoint-corpus/**' + - 'requirements/debugpy.txt' + - 'pnpm-lock.yaml' + - '.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: + python-version: ['3.12', '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, and the process settings + 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 tests/adapters/python/integration/python-logpoint-process-settings.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..43631c249 --- /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 the check finds 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 logs in its place; 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`, a child process whose interpreter cannot be confirmed as the checked one, and a check that ran out of its time (2 s from the question, 5 s when it starts the checker, so a `set_breakpoint` waits no longer). The checker relaxes the settings of its own process that the compiler is known to consult (the integer digit limit, warnings filters), and where it cannot relax one and can tell (its recursion limit, its memory, an audit hook added from Python) it answers "not checked" instead of failing the message. The Python guide lists the limits: a program that made its own compiler stricter can still fail where the check said it runs, a message with a starred group (`{*items}`) has the `%` in its text left unexamined, and an audit hook registered from C in the checker's process is not told apart from the compiler (#1334, #1349) diff --git a/docs/python/README.md b/docs/python/README.md index 1dfcc830c..90b6a117b 100644 --- a/docs/python/README.md +++ b/docs/python/README.md @@ -65,6 +65,23 @@ 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 takes a launched session (the launches that are not checked are listed below). 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 wherever the check finds 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 on 3.12 too with some debugpy versions (1.8.0 does, 1.8.20 does not) — and names the f-string reading. +- A message the check finds 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 with a starred group (`{*items}`) is the exception for `%` (below). +- 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 why and what every hit logs in its place: a compile error, a `%` formatting error or debugpy's "Unbalanced braces" line, with CPython's words where CPython has some. +- 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 and precisions adding up to more than 65,536 (a message with a starred group is not held to these, since its `%` is not examined at all), anything the check itself could not finish (its recursion limit, its memory, the interpreter's own tokenizer raising on a field, which Python 3.12.13's does on one known shape, an audit hook added from Python in its process that raised while it compiled), and a check that ran out of time (below). + +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 (when the program and every child process it started have ended), on `close_debug_session` (which waits for it), and when the server exits; it reads its input until the server goes away. A check has 2 seconds from the moment it is asked, waiting behind other checks included, or 5 seconds when it starts the helper: a `set_breakpoint` is delayed by no more than that however many calls arrive at once, and past it the message is sent as written and the answer says it was not checked. A launch's checks share one such budget. When the helper cannot be started, exits before it has answered, or does not answer in its first 5 seconds, the run's later checks are answered at once as not checked, with that reason, and nothing is started again until the next run; a helper that fails after it had answered is started again once in the run. + +The check is a verdict in one direction only. What it finds cannot compile is a fact about the text, meant to hold in every process: the helper is a sibling of the program on the same interpreter binary, and the settings of its own process that the compiler is known to consult are relaxed in it — the integer digit limit lifted, warnings ignored, its working directory kept off the path of the modules the compiler imports — and what it cannot relax (the recursion limit, memory, an audit hook added from Python) makes the message not checked instead of failed. One thing in its own process it does not tell from the compiler is an audit hook registered from C (below). What it finds compiles can still fail at a hit in a program that made its own compiler stricter: one that turns warnings into errors (`-W error`, `PYTHONWARNINGS=error`, `warnings.simplefilter("error")`: `{1 is 1}` then logs `"is" with 'int' literal`), one that lowered the integer digit limit (`sys.set_int_max_str_digits(640)`, `PYTHONINTMAXSTRDIGITS`: a long literal then logs `Exceeds the limit (640 digits)`), one with a lower recursion limit or a deeper stack at the hit, one with an audit hook, and a child process started with interpreter flags of its own (`-W error`, `-X int_max_str_digits=640`), which a child's check, made on the same interpreter binary, does not see. That is what "this check did not execute a hit" in the answer means. A repair claims only a compile: it was not run, and real values can still raise. A message with a starred group (`{*items}`) is checked for what compiles only, whatever the verdict: how many values the group gives is known at the hit alone, so the text's `%` is not examined and never doubled. `{*items} 100%` is answered as running and `{x!r} {*items} 100%` is sent as `{f'{x!r}'} {*items} 100%`; every hit of either logs an error in its place. 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. + +Four more things a user can meet, each with what the check does there. On macOS (and other systems without `/proc`) a child process's executable cannot be looked up, so every logpoint of an adopted child there is not checked (the root's are). The helper runs with the debug adapter's environment and working directory, not the launch's `env` or `envFile`: what a launch sets for the program alone (`PYTHONWARNINGS=error`, a `PYTHONPATH`) is not seen by the check, which answers as if it were not set, and is one more way a program can be stricter than its check. A file on the `PYTHONPATH` the helper inherits that stands in for a module the compiler uses (`unicodedata`) and leaves it without its table of character names makes every check of that run not checked; that takes an interpreter that loads the module from a file, and one that has it built in (Ubuntu 24.04's own Python 3.12 is one) never loads the file and answers as usual. An audit hook registered from C in the helper's process (an extension calling `PySys_AddAuditHook`) is not told apart from the compiler, as a hook added from Python is: a `SyntaxError` or `ValueError` it raises while the check compiles is read as the text's, and the message can then be answered as failing, or be rewritten. + ### 3. Start Debugging Start debugging your Python script: diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 6aa321a03..1058aad56 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'; @@ -313,7 +323,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..3ec33be98 --- /dev/null +++ b/packages/shared/src/interfaces/python-logpoint-check.ts @@ -0,0 +1,699 @@ +/** + * 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, a hook): sent as written. A limit of this process is never a verdict on the text. + +This process is a sibling of the program on the same interpreter binary, not the program: what +a process can set for itself, the program may have set otherwise. So every setting CPython's +compiler and tokenizer consult that a process can change is put in its most permissive state +here, and a compile failure seen here is one in every process; where that cannot be done, the +failure is declined ("unchecked"), never a verdict. (Read in the 3.11, 3.12 and 3.13 sources.) + + integer digit limit -X int_max_str_digits, PYTHONINTMAXSTRDIGITS, sys.set_int_max_str_digits: + a longer decimal literal is a SyntaxError (Parser/pegen.c, + _PyPegen_number_token). Lifted: sys.set_int_max_str_digits(0). + warnings filters -W, PYTHONWARNINGS, warnings.simplefilter: under "error" a warning the + compiler or tokenizer emits becomes a SyntaxError (Python/compile.c + compiler_warn; Parser/tokenizer.c, 3.13 Parser/tokenizer/helpers.c + parser_warn and the invalid-escape warning; Parser/string_parser.c). + Ignored from the start, before any import, and again around every + compile, parse and tokenize (_permissive). + recursion limit 3.11 compiles to sys.getrecursionlimit() * 3 less the caller's depth + (Python/symtable.c, Python/ast_opt.c), 3.12+ to the C recursion budget + left: a RecursionError, never a verdict (Decline). The parser's own + stack (Parser/parser.c MAXSTACK) and nesting limits are build constants. + audit hooks sys.addaudithook: compile() raises the "compile" event first + (Parser/peg_api.c), and a hook may raise anything. A SyntaxError or + ValueError counts only when compile() itself raised it (_from_compile). + unicodedata a named escape (backslash, N, a name in braces) and a non-ASCII name + need the module (Objects/unicodeobject.c, Parser/pegen.c); a failed + import makes the escape a SyntaxError. Imported from the standard + library at start, the working directory left out, and the escape + primed once; when that fails every check declines. + future imports compile() inherits the caller's; dont_inherit here, and pydevd's eval + at a hit (pydevd.py, no __future__ import) inherits none either. + optimization level -O only folds __debug__ (Python/ast_opt.c); no compile fails by it. + memory MemoryError, never a verdict (Decline). + PYTHONIOENCODING overrides -X utf8 for the standard streams: the questions and answers + go through their bytes, ASCII either way (serve). + +The other way round stays advisory: a program that lowered the digit limit, turned warnings +into errors, has another recursion depth or hooks, or a child started with other interpreter +flags, can fail at a hit on a message that compiles here. +""" +import sys + +# The standard library first: "-c" puts the working directory (the program's) first on the path, +# where a file named like a module this check or the compiler imports would shadow it. +_cwd_entries = sys.path[:1] if sys.path[:1] == [""] else [] +del sys.path[:len(_cwd_entries)] +try: + import ast + import io + import json + import os + import re + import tokenize + import warnings + # This process acts on no warning: one an import below raises under PYTHONWARNINGS=error would + # otherwise stop it before a message is read. (Every compile also runs under _permissive.) + warnings.simplefilter("ignore") + try: + import unicodedata # noqa: F401 the compiler's: \N{...} escapes, non-ASCII names + compile(r'"\N{BULLET}"', "", "eval", dont_inherit=True) # loads the name table once + SETUP_ERROR = None + except Exception as e: # noqa: BLE001 + SETUP_ERROR = "the compiler's unicodedata module could not be loaded here (%s)" % type(e).__name__ +finally: + sys.path[:0] = _cwd_entries + +if hasattr(sys, "set_int_max_str_digits"): + sys.set_int_max_str_digits(0) + +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]) + + +class _permissive(warnings.catch_warnings): + """Every warning ignored: under an "error" filter the compiler turns one into a SyntaxError.""" + + def __enter__(self): + entered = super().__enter__() + warnings.simplefilter("ignore") + return entered + + +def _from_compile(e): + """Whether compile() itself raised e: no Python frame ran below the call (an audit hook's + would be on the traceback).""" + return e.__traceback__ is None or e.__traceback__.tb_next is None + + +def _compile(src, flags): + """compile(src) as an expression; None for a SyntaxError or ValueError of the text, which is + returned with the result. Decline on anything else: a limit or a hook of this process.""" + try: + with _permissive(): + return compile(src, "", "eval", flags, dont_inherit=True), None + except (SyntaxError, ValueError) as e: + if not _from_compile(e): + raise Decline("something in this process raised %s while compiling (an audit hook?)" % type(e).__name__) + return None, 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 _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, in every process).""" + return _compile(src, 0)[1] + + +def _tree(src): + """The expression's AST (ast.parse(src, mode="eval")), or None when it is a syntax error.""" + return _compile(src, ast.PyCF_ONLY_AST)[0] + + +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)}) + + +_FSTRING_START = getattr(tokenize, "FSTRING_START", None) # 3.12+: an f-string is several tokens +_FSTRING_END = getattr(tokenize, "FSTRING_END", None) +_LAYOUT = {tokenize.NEWLINE, tokenize.NL, tokenize.ENDMARKER, tokenize.INDENT, tokenize.DEDENT} + + +def _whole_literal(src): + """Whether the tokenizer reads src as one string literal and nothing else. A group that holds + the delimiter can end the f-string early and go on as another literal joined to it, or as + a comment that hides the rest of the group (f"{{" f"{y + '}}'}" on 3.12+).""" + try: + with _permissive(): + tokens = list(tokenize.generate_tokens(io.StringIO(src).readline)) + except (tokenize.TokenError, SyntaxError): + return False + except Exception as e: # noqa: BLE001 3.12's tokenize module raises SystemError on some f-strings it compiles + raise Decline("the tokenizer failed here (%s)" % type(e).__name__) + depth = top = 0 + for tok in tokens: + if _FSTRING_START is not None and tok.type == _FSTRING_START: + top += depth == 0 + depth += 1 + elif _FSTRING_END is not None and tok.type == _FSTRING_END: + depth -= 1 + elif depth == 0 and tok.type not in _LAYOUT: + top += 1 + return top == 1 + + +def field_form(raw): + """f{raw}: the same field as an f-string, when CPython reads it as exactly one field. + Each delimiter is tried on every version: whether the group can hold it (an escaped quote in + a format spec, a single quote in a triple-quoted literal) is the tokenizer's to say.""" + for q in ("'", '"', "'''", '"""'): + src = "f" + q + "{" + raw + "}" + q + tree = _tree(src) + if tree is None or _syntax_error(src) is not None or not _whole_literal(src): + 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 SETUP_ERROR is not None: + return {"status": "unchecked", "cause": SETUP_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 + try: + f = field_form(v) + except Decline: + continue # the reading is a remark: one that cannot be established is left out + 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(): + # The bytes of the pipes, not their text: PYTHONIOENCODING takes precedence over -X utf8 for + # sys.stdin and sys.stdout, and the protocol is ASCII either way. + for line in sys.stdin.buffer: + 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.buffer.write((json.dumps(res, ensure_ascii=True) + "\n").encode("ascii")) + sys.stdout.buffer.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. A + * compile failure is one the checker saw with every setting a process can + * relax relaxed, so it fails in every process; which error a hit logs can + * differ in a program that made the compiler stricter, so the sentence quotes + * CPython's text as what the checker saw, not as the line every hit logs. + */ +function asWritten(cause: CheckerCause): string { + switch (cause.kind) { + case 'compile': + return `it does not compile (CPython: ${quote(cause.text)}), so as written every hit logs a compile error instead`; + 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 version = major === null ? 0 : Number(major[1]) * 100 + Number(major[2]); + // Measured in the live corpus: 3.13 writes a hit's assignment into the frame (PEP 667); on 3.12 + // it depends on how debugpy traces the program (1.8.0 does, 1.8.20 does not); 3.11 does not. + 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' + + (version >= 313 + ? `, and on Python ${python} that can change the running function's own variable.` + : version === 312 + ? `, and on Python ${python} that can change the running function's own variable, depending on the debugpy version (1.8.0 does, 1.8.20 does not).` + : '.') + + 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 f6e5ed52e..511388869 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..3fe97c35a 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. A check waits at most 2 s (5 s when it starts the checker) and otherwise answers "not checked"; a program that turns warnings into errors or lowers its integer digit limit can still fail on a message the check said runs. 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 92e233758..925d08378 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'; @@ -663,12 +664,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 56d82407d..e367fc88c 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 d4906427b..cdf9e24a4 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'; @@ -499,7 +500,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 fe293c773..1006a22bf 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, RUN_CHANGED_VERDICT, verdictFor } from './logpoint-checks.js'; import { applyBoundLocation, keepHitProven, @@ -206,6 +207,22 @@ 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 the + // session's first run, or after its run is over, is checked by the next + // launch. A verdict from a run that ended while it was asked is not kept: + // the record says it was not checked, and why, rather than nothing. + 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); + applyLogMessageVerdict( + newBreakpoint, + checking.isCurrent() || verdict === undefined || verdict.status === 'refused' ? verdict : RUN_CHANGED_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..ab14d1f0d --- /dev/null +++ b/src/session/breakpoints/logpoint-checks.ts @@ -0,0 +1,148 @@ +/** + * 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; +} + +/** A verdict asked in a run that ended before it came back: what the record keeps instead of nothing. */ +export const RUN_CHANGED_VERDICT: LogMessageVerdict = Object.freeze({ + status: 'unchecked', + note: 'Not checked (the run it was checked on ended while it was being checked); sent as written.' +}); + +/** 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()) { + // The run ended while it checked: its verdicts are not kept, and a record + // the check had cleared says so rather than nothing. One that holds a + // verdict already got it from a newer run's check, which stands. + for (const bp of logpoints) { + if (isStored(bp) && bp.logMessageVerdict === undefined) { + applyLogMessageVerdict(bp, RUN_CHANGED_VERDICT); + } + } + 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 b8baed2a9..d69efb880 100644 --- a/src/session/launch/debug-launcher.ts +++ b/src/session/launch/debug-launcher.ts @@ -39,6 +39,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, @@ -921,6 +922,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 b01f56462..d4dcbf6aa 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, 'a new run of this session is starting; its launch checks the logpoints it has'); // 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..54a1bd265 --- /dev/null +++ b/src/session/log-message-checkers.ts @@ -0,0 +1,635 @@ +/** + * 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 from the question, not from the process: a check (one handle, one + * validation: a live `set_breakpoint`'s message, a child's two questions, a + * launch's or an adoption's whole batch) has one budget, starting at its + * first question and covering every question it asks, queue time included: + * `startMs` when the run's checker has not answered yet (its start is in + * it), else `requestMs`. A question whose budget ends while it waits its + * turn is answered "not checked" and never sent; one whose budget ends while + * the process works on it is answered "not checked", and the process's late + * answer settles that question only (answers come in order, one question in + * flight), so it never reaches another. So the check delays a live + * `set_breakpoint` by at most `requestMs` (2 s), or `startMs` (5 s) when it + * asks the run's first question, however many calls are waiting. The + * process itself is bounded too: an answer within `startMs` of sending the + * first question and `requestMs` of every later one, or it is killed; 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 and every descendant are + * terminal, or the root is removed: a child still being debugged keeps its + * tree's checker), when the next run of the session begins, when a failed + * process is replaced, when the session closes and at server exit: 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`. A session's close awaits every stop that + * belongs to it (a previous run's, a replaced process's, its current run's), + * so no checker of it outlives `close_debug_session`; server exit awaits + * them all. + * - 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 the state changes and removals of a root session and its descendants; returns the unsubscribe. */ + watch: (sessionId: string, listener: () => void) => () => void; + /** Whether the root's run is over: the root and every descendant are terminal, or the root is gone. */ + runEnded: (sessionId: string) => boolean; + spawn?: CheckerSpawn; + bounds?: Partial; +} + +/** A check's budget: when its time is up, from its first question. */ +interface CheckBudget { + at: number; + ms: number; + /** It began before the run's checker had answered: its start is in it. */ + cold: boolean; +} + +/** + * A handle with no checker behind it: every question is answered with + * `cause`, so a policy says "not checked" and why — never nothing. + */ +export function unavailableChecker(cause: string): LogMessageChecker { + return { ask: () => Promise.resolve({ ok: false, cause }) }; +} + +/** + * 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; + }); + } + + /** 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 within its check's budget, queue time included. + * Questions run one at a time, in order; one whose budget is up when its + * turn comes is never sent — decided on the clock when the turn comes, not + * on whether the budget's timer has run yet (an answer read in the poll + * phase lets the next question's turn come before the timers phase) — and + * one that is answered after its budget is up settles only itself (the turn + * moves on when the process answers or fails). Never rejects. + */ + ask(line: string, budget: CheckBudget): Promise { + const late = (): LogMessageCheckerReply => ({ + ok: false, + cause: budget.cold + ? `the checker did not start and answer within ${budget.ms} ms of the check` + : `the checker did not answer within ${budget.ms} ms of the check` + }); + let expired = false; + const reply = this.turn.then(() => (expired || Date.now() >= budget.at ? late() : this.send(line))); + this.turn = reply; + const left = budget.at - Date.now(); + const expire = (): LogMessageCheckerReply => { + expired = true; + return late(); + }; + return left > 0 ? bounded(left, reply, expire) : Promise.resolve(expire()); + } + + 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>(); + /** Per root session: every stop under way of a checker that belonged to it, whichever run. */ + private readonly stops = new Map>>(); + /** Per root session: why its last run ended, while no run follows it. */ + private readonly endings = new Map(); + 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, 'a new run of this session began'); + if (this.options.runEnded(rootSessionId)) { + this.runs.delete(rootSessionId); + return undefined; + } + this.endings.delete(rootSessionId); + 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, 'the program and every child process it started have ended'); + } + }); + this.watches.set(rootSessionId, unsubscribe); + } + return generation; + } + + /** + * The handle `validateLogMessage` asks through, for the session's current + * run; undefined with no run. One handle is one check: its budget starts at + * its first question and covers every question asked through it. + */ + 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; + let budget: CheckBudget | undefined; + return { + ...(run.binding.launchConfig ? { launchConfig: run.binding.launchConfig } : {}), + ...(child ? { child } : {}), + ask: (spec, request) => { + budget ??= this.budgetFor(run, spec); + return this.ask(rootSessionId, generation, spec, request, budget); + } + }; + } + + /** + * Every stop under way of a checker of the root's tree, whichever run, when + * they are all done: what closing a descendant awaits, since that close can + * end the tree's run (the last live child of a root that has ended). + */ + async settled(rootSessionId: string): Promise { + await Promise.all([...(this.stops.get(rootSessionId) ?? [])]); + } + + /** Why the root's last run ended, while no run follows it (for the "not checked" a live session then gets). */ + endedBecause(rootSessionId: string): string | undefined { + return this.endings.get(rootSessionId); + } + + /** 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; + } + + /** A check's budget from now: the start's when the run's process for the spec has not answered yet. */ + private budgetFor(run: RunState, spec: LogMessageCheckerSpec): CheckBudget { + const process = run.processes.get(spec.key); + const cold = !(process !== undefined && process.failure === undefined && process.started); + const ms = cold ? this.bounds.startMs : this.bounds.requestMs; + return { at: Date.now() + ms, ms, cold }; + } + + private async ask( + rootSessionId: string, + generation: number, + spec: LogMessageCheckerSpec, + request: unknown, + budget: CheckBudget + ): 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, budget); + } + + /** 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(rootSessionId, 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 (`why`, for a live session's "not checked" until the next run): stop its checkers. Idempotent. */ + endRun(rootSessionId: string, why: string): Promise { + const run = this.runs.get(rootSessionId); + if (!run) { + return Promise.resolve(); + } + if (!run.ended) { + this.endings.set(rootSessionId, why); + } + run.ended = true; + const stopping = Promise.all([...run.processes.values()].map((p) => p.stop('the run ended'))).then(() => undefined); + return this.track(rootSessionId, stopping); + } + + /** The session closes: every checker it had is stopped and awaited, whichever run it was of, and it is forgotten. */ + async closeSession(rootSessionId: string): Promise { + this.endRun(rootSessionId, 'the session closed'); + this.runs.delete(rootSessionId); + this.endings.delete(rootSessionId); + this.watches.get(rootSessionId)?.(); + this.watches.delete(rootSessionId); + await Promise.all([...(this.stops.get(rootSessionId) ?? [])]); + } + + /** 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.values()].flatMap((stops) => [...stops])); + } + + private track(rootSessionId: string, stop: Promise): Promise { + let stops = this.stops.get(rootSessionId); + if (!stops) { + stops = new Set(); + this.stops.set(rootSessionId, stops); + } + const own = stops; + own.add(stop); + const forget = (): void => { + own.delete(stop); + if (own.size === 0 && this.stops.get(rootSessionId) === own) { + this.stops.delete(rootSessionId); + } + }; + stop.then(forget, forget); + return stop; + } +} diff --git a/src/session/operations-context.ts b/src/session/operations-context.ts index 23881a394..177e590b9 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'; @@ -189,6 +191,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; } /** @@ -208,6 +220,7 @@ export type ProxyLaunchContext = Pick< | 'findFreePort' | 'setupProxyEventHandlers' | 'redactionEnabled' + | 'logMessageCheckers' >; /** @@ -273,10 +286,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 2510b8301..acda3fc5f 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 { StateShadow } from './machine/shadow.js'; @@ -59,6 +60,8 @@ import { quotesAdapterStderrLine } from './launch/proxy-failure-diagnostics.js'; import type { AnchorResolution } from './breakpoints/anchor-resolution.js'; +import { LogMessageCheckers, unavailableChecker } from './log-message-checkers.js'; +import { checkLogpoints, clearLogMessageCheck, type LogpointCheckNote } from './breakpoints/logpoint-checks.js'; import { applyBoundLocation, applyHitBreakpointIds, @@ -130,6 +133,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[]; } /** @@ -531,6 +536,13 @@ 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; /** * The transition table's shadow check (src/session/machine/shadow.ts): * every gate call and every note is judged against the table and recorded. @@ -568,6 +580,15 @@ export abstract class SessionManagerCore extends EventEmitter { }); this.fileSystem.ensureDirSync(this.logDirBase); + this.logMessageCheckers = new LogMessageCheckers({ + logger: this.logger, + // The run is the tree's: it lasts while the root or any descendant is being debugged. + watch: (sessionId, listener) => this.onSubtreeStateChange(sessionId, listener), + runEnded: (sessionId) => { + const session = this.sessionStore.get(sessionId); + return !session || [session, ...this.descendantsDeepestFirst(sessionId)].every((s) => isTerminalSessionState(s.state)); + } + }); this.logger.info(`[SessionManager] Initialized. Session logs will be stored in: ${this.logDirBase}`); } @@ -1488,6 +1509,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, { site: 'closeSingleSession', event: 'close' }); // Also update session lifecycle to TERMINATED @@ -1505,8 +1529,15 @@ export abstract class SessionManagerCore extends EventEmitter { // and a wait on an ancestor's tree sees one descendant fewer (issue #1081). this.notifySessionStateListeners(sessionId); this.sessionStateListeners.delete(sessionId); + const treeRootId = session.parentSessionId ? this.rootOf(session).id : undefined; this.notifySubtreeListeners(session); this.subtreeListeners.delete(sessionId); + if (treeRootId !== undefined) { + // The last live descendant of a root that has ended ends the tree's run + // with this removal (the notification above): its checker stops before + // this close answers, as a root's close waits for its own (issue #1334). + await this.logMessageCheckers.settled(treeRootId); + } if (session.parentSessionId) { // A child's view reports the shared worker's pid, which legitimately // lives on (issue #1081); the leak probe is the root's. Its end may @@ -1614,6 +1645,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'); } @@ -1746,6 +1779,37 @@ 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 only for a root that has no run because it has + * not started or its run is over: its next launch checks its logpoints and + * says so in its answer. Every other session gets a handle — one with no + * checker behind it when there is none to ask, which answers why, so the + * policy's verdict is "not checked" with the reason and never nothing. + */ + protected logpointCheckerOf(session: ManagedSession): { checker: LogMessageChecker; isCurrent: () => boolean } | undefined { + const root = this.rootOf(session); + const isChild = session.parentSessionId !== undefined; + const checkers = this.logMessageCheckers; + const generation = checkers.currentGeneration(root.id); + if (generation === undefined) { + if (!isChild && (session.state === SessionState.CREATED || isTerminalSessionState(session.state))) { + return undefined; + } + return { + checker: unavailableChecker(checkers.endedBecause(root.id) ?? 'no run of this session is under way to check it on'), + isCurrent: () => checkers.currentGeneration(root.id) === undefined + }; + } + const isCurrent = (): boolean => checkers.currentGeneration(root.id) === generation; + if (isChild && session.childReport === undefined) { + return { checker: unavailableChecker("the child's report was not kept, so the interpreter it runs on is not known"), isCurrent }; + } + const checker = checkers.checkerFor(root.id, isChild ? session.childReport : undefined); + return { checker: checker ?? unavailableChecker('the run ended while it was being checked'), isCurrent }; + } + /** * 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 @@ -1833,12 +1897,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() ?? []) { @@ -1855,17 +1922,33 @@ 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; + } + // A child always gets a handle (logpointCheckerOf): with no checker to ask, it answers why. + 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 53a04b75e..1b61bc110 100644 --- a/src/session/session-manager-operations.ts +++ b/src/session/session-manager-operations.ts @@ -205,7 +205,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 48676c661..fc5823865 100644 --- a/src/session/session-store.ts +++ b/src/session/session-store.ts @@ -321,6 +321,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..90bbdaf11 --- /dev/null +++ b/tests/adapters/python/integration/logpoint-corpus/corpus.json @@ -0,0 +1,5218 @@ +{ + "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, 3.12.13 and 3.13.12. The lines are pins for those minor versions (see logpoint-pins.ts); assignedAsWritten and assignedSent say what that debugpy did and are not compared.", + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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 '%' (0x25) 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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "envs": { + "A": { + "asWritten": " at 0x\u2026>" + }, + "B": { + "asWritten": " at 0x\u2026>" + } + }, + "live": { + "asWritten": " at 0x0000016FC1CC1A80>" + } + }, + "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.12": { + "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.12": { + "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]" + } + }, + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "envs": { + "scopes": { + "asWritten": "function: ['closure'] | class: ['class-free']" + } + } + }, + "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.12": { + "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']" + } + } + }, + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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", + "linesDependOn": "how deep the compiler can go at the hit. On 3.12 and 3.13 the budget is the C stack's (Py_C_RECURSION_LIMIT, set per platform and build, less the depth already in use): Linux compiles the 3,000 nested additions and logs 3000, Windows raises RecursionError. On 3.11 it is sys.getrecursionlimit() less the frames in use, a setting of the program. None of it is the text's or the minor version's: the row's verdict (not checked: longer than the message bound) is pinned, its lines are not, and the properties hold it as any row", + "expect": { + "3.11": { + "status": "unchecked" + }, + "3.12": { + "status": "unchecked" + }, + "3.13": { + "status": "unchecked" + } + } + }, + { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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 '%' (0x25) 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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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 '%' (0x25) 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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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 0x0000016FC3795B20> '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.12": { + "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.12": { + "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.12": { + "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..59d32d660 --- /dev/null +++ b/tests/adapters/python/integration/logpoint-corpus/emulate.py @@ -0,0 +1,548 @@ +"""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 ast +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) + + +UNBALANCED = re.compile(r"^(['\"])Unbalanced braces in: ") + + +def pydevd_outcome(expr, frame): + """What pydevd's eval of its expression does at a hit in this frame, by where it stops: + None (it runs: the line is the message), "unbalanced" (pydevd's own line about the braces, + not an evaluation), "compile" (it does not compile), "value" (evaluating a group raised: + the program's values, not the text) or "percent" (the groups evaluated and the %-template + rejected them). The steps are the ones eval takes: compile, the tuple, then the %.""" + return pydevd_outcome_text(expr, frame)[0] + + +def pydevd_outcome_text(expr, frame): + """pydevd_outcome, with what the line says when it is not the message: the exception's text, + or pydevd's braces line. property_violations checks it against pydevd's own hit.""" + if UNBALANCED.match(expr): + return "unbalanced", ast.literal_eval(expr) + try: + compile(expr, "", "eval") + except BaseException as e: # noqa: BLE001 + return "compile", str(e) + body = ast.parse(expr, mode="eval").body + if not (isinstance(body, ast.BinOp) and isinstance(body.op, ast.Mod) and isinstance(body.right, ast.Tuple)): + return None, None # no group: the text itself + try: + values = eval(compile(ast.Expression(body.right), "", "eval"), frame.f_globals, frame.f_locals) + except BaseException as e: # noqa: BLE001 + return "value", str(e) + try: + body.left.value % values + except BaseException as e: # noqa: BLE001 + # With a starred group, how many values the template gets is itself a value. + starred = any(isinstance(elt, ast.Starred) for elt in body.right.elts) + return ("value" if starred else "percent"), str(e) + return None, None + + +def hit_in_function(message, env, globals_extra=None, patch_repr=False, probe=pydevd_hit): + 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: probe(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, probe=pydevd_hit, which=None): + expr = conv(message) + + def outer(): + free = "closure" + + def inner(): + local = free + "-local" # noqa: F841 + return probe(expr, sys._getframe()) + return inner() + + class C: + local, free = "class-local", "class-free" + res = probe(expr, sys._getframe()) if which != "function" else None + if which == "function": + return {"log": outer()} + if which == "class": + return {"log": C.res} + return {"log": "function: %s | class: %s" % (outer(), C.res)} + + +def hit(message, env_name, probe=pydevd_hit): + if env_name.startswith("scopes"): + return hit_scopes(message, probe, env_name.partition(":")[2] or None) + if env_name in ("A", "B"): + return hit_in_function(message, ENV_A if env_name == "A" else ENV_B, probe=probe) + if env_name in ("T", "TB"): + return {"log": (_works_a if env_name == "T" else _works_b)(lambda fr: probe(conv(message), fr))} + if env_name == "globalY": + return hit_in_function(message, SPECIAL[env_name], globals_extra={"y": 99}, probe=probe) + return hit_in_function(message, SPECIAL[env_name], patch_repr=(env_name == "patchedBuiltinRepr"), probe=probe) + + +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] + + +# The guarantee, against this interpreter and its debugpy, with no recorded line: per row, the +# verdict and the wire, and what the message as written and the wire do at pydevd's hit in each +# of the row's value environments (pydevd_outcome). "Logs an error" is any outcome but None. +# Whether a message can run is about the text, and the environments' values can make any group +# or any %-directive fail (a string for %d, a name a nested scope cannot see), so "runs" is held +# to what it says and no more: no environment's hit is a compile error or the braces line, and +# its %-template formats when every element is 1 (formats_with_ones, the verdict's own +# definition, computed here from the conversion's AST; a starred group's count is a value). +# runs the wire is the message; as written: no compile error, no braces line, formats with 1 +# rewritten as written the hit logs an error in every environment; the wire: as "runs" says, and +# its %-template did not reject the values in every environment whose groups evaluated +# (the check chose this wire: after its validation the template's only directives +# take its groups, %s each, so a % failure everywhere is the rewrite's, not a value's) +# fails the wire is the message, and as written the hit logs an error in every environment +# unchecked the wire is the message +TEXT_ERRORS = ("unbalanced", "compile") + + +def formats_with_ones(message): + """Whether debugpy's %-template for message formats with every element 1 (True when it has + no template, or a starred group decides how many elements there are).""" + expr = conv(message) + if UNBALANCED.match(expr): + return True + try: + body = ast.parse(expr, mode="eval").body + except BaseException: # noqa: BLE001 a compile error, judged on its own + return True + if not (isinstance(body, ast.BinOp) and isinstance(body.op, ast.Mod) and isinstance(body.left, ast.Constant) + and isinstance(body.right, ast.Tuple)): + return True + if any(isinstance(elt, ast.Starred) for elt in body.right.elts): + return True + try: + body.left.value % ((1,) * len(body.right.elts)) + return True + except BaseException: # noqa: BLE001 + return False + + +def _can_run(message, outcomes): + return not any(o in TEXT_ERRORS for o in outcomes.values()) and formats_with_ones(message) + + +def _percent_everywhere(outcomes): + """The %-template rejected the values in every environment whose groups evaluated, and there + was at least one (one where a group raised first never reached the %).""" + reached = [o for o in outcomes.values() if o != "value"] + return bool(reached) and all(o == "percent" for o in reached) + + +def property_violations(m, verdict, envs, run_hits=True): + status, wire = verdict.get("status"), verdict.get("wire", m) + if status not in ("runs", "rewritten", "fails", "unchecked"): + return ["status %r" % (status,)] + out = [] + if status == "rewritten" and wire == m: + out.append("rewritten, but the wire is the message") + if status != "rewritten" and wire != m: + out.append("%s, but the wire is not the message" % status) + if status == "unchecked" or not run_hits: + return out + + def outcomes(message): + """Per environment, where the evaluation stopped; and that the staged reading is pydevd's: + when it stopped on an error, pydevd's own hit logged exactly that error's text.""" + found = {} + for e in envs: + kind, text = hit(message, e, pydevd_outcome_text)["log"] + line = hit(message, e)["log"] + if kind is not None and (line is None or line != ADDR.sub("0x…", text)): + out.append("the staged outcome of %r in %s is %s %r, but pydevd's hit logged %r" % (message[:80], e, kind, text, line)) + found[e] = kind + return found + + as_written = outcomes(m) + if status == "runs" and not _can_run(m, as_written): + out.append("runs, but as written it cannot run: %r, formats with 1: %r" % (as_written, formats_with_ones(m))) + if status in ("rewritten", "fails") and any(o is None for o in as_written.values()): + out.append("%s, but as written the hit ran in %r" % (status, [e for e, o in as_written.items() if o is None])) + if status == "rewritten": + sent = outcomes(wire) + if not _can_run(wire, sent) or _percent_everywhere(sent): + out.append("rewritten, but the wire cannot run: %r, formats with 1: %r" % (sent, formats_with_ones(wire))) + return out + + +def _row_envs(row): + if "env" in row: + return [row["env"]] + return ["scopes:function", "scopes:class"] if row.get("frame") else ["A", "B"] + + +def run_properties(): + out = {"counts": {"corpus": {}, "table": {}, "mixed": {}}, "violations": {}} + for row in json.load(open(os.path.join(HERE, "corpus.json"), encoding="utf-8"))["rows"]: + m = corpus_message(row) + v = check(m) + counts = out["counts"]["corpus"] + counts[v["status"]] = counts.get(v["status"], 0) + 1 + bad = property_violations(m, v, _row_envs(row), run_hits=row.get("hit") is not False) + if bad: + out["violations"]["corpus:" + row["id"]] = {"msg": m[:300], "verdict": v, "violations": bad} + for row in json.load(open(os.path.join(HERE, "table.json"), encoding="utf-8"))["rows"]: + v = check(row["msg"]) + counts = out["counts"]["table"] + counts[v["status"]] = counts.get(v["status"], 0) + 1 + bad = property_violations(row["msg"], v, ["T", "TB"]) + if bad: + out["violations"]["table:" + row["key"]] = {"msg": row["msg"], "verdict": v, "violations": bad} + # Messages of two and three groups of every kind, with %-texts (fuzz.mixed), in environments A and B. + counts = out["counts"]["mixed"] = {} + for m in fuzz.mixed()[::1 if not QUICK else 7]: + v = check(m) + counts[v["status"]] = counts.get(v["status"], 0) + 1 + bad = property_violations(m, v, ["A", "B"]) + if bad: + out["violations"]["mixed:" + m] = {"msg": m, "verdict": v, "violations": bad} + return out + + +class _Matrix: + def __getitem__(self, key): + return "M[%r]" % (key,) + + +def _works_a(hook): + """A frame with the table's values (T), handed to hook.""" + 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 + return hook(sys._getframe()) + + +def _works_b(hook): + """A frame with other types, None and empty values (TB), handed to hook.""" + 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 + return hook(sys._getframe()) + + +def _eval_in(expr): + return lambda frame: eval(expr, frame.f_globals, frame.f_locals) # what pydevd does at a hit + + +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(_eval_in(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, + "mixed-groups": fuzz.mixed()} + 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 + # Rows for the delimiter (the second review's R8): every version tries every delimiter and the + # tokenizer decides. An escaped quote in a format spec is one literal on 3.11 too... + "{x:\\'}", + # ...and a group holding the delimiter that would end the f-string and start another is not. + "{{' f'{x + \"}}\"}", + # A group of two elements beside a rewritten one: the template and the tuple no longer line up, + # which the arity check and the untouched-group check each catch (the second review: PM4). + "%d {x!r} {1, 2}", + # A group whose f-string form parses and does not compile (an assignment in a comprehension's + # iterable): no form, and the answer names the group (PM2). + "{[v for v in (n := items)]!r}", +] + + +def run_extra(): + out = [] + for m in EXTRA: + v = check(m) + wire = v.get("wire", m) + row = {"status": v["status"], "wire": wire if wire != m else None, "logA": hit(wire, "A")["log"]} + for field in ("group", "note"): + if field in v: + row[field] = v[field] + out.append(row) + return out + + +# A group whose f-string form a working tokenizer reads as one literal, and some 3.12 releases' +# tokenize module cannot read at all (3.12.13: SystemError, "Negative size passed to PyUnicode_New"; +# 3.12.3, 3.11, 3.13 and 3.14 read it): where the tokenizer fails, the check cannot finish and the +# message is not checked, never "fails" for a message that a working tokenizer repairs (the +# mutation pass's F9 read the failure as "not one literal"). It takes a lambda's default and a +# dict display holding a newline. What this interpreter's tokenizer does with the form is reported +# with the verdict: it differs between patch releases of one minor version, so no pin can hold it. +TOKENIZER_ROW = "{(lambda q=1:q)()or{1:2" + chr(10) + "}!r}" + + +def run_tokenizer_row(): + import io + import tokenize + + raised = set() + for q in ("'", '"', "'''", '"""'): + form = "f" + q + "{" + TOKENIZER_ROW[1:-1] + "}" + q + try: + list(tokenize.generate_tokens(io.StringIO(form).readline)) + except (tokenize.TokenError, SyntaxError): + pass + except Exception as e: # noqa: BLE001 what the checker declines on + raised.add(type(e).__name__) + v = check(TOKENIZER_ROW) + wire = v.get("wire", TOKENIZER_ROW) + return {"tokenizerRaises": sorted(raised), "status": v["status"], + "cause": v.get("cause") if v["status"] == "unchecked" else None, + "wire": wire if wire != TOKENIZER_ROW else None, "logA": hit(wire, "A")["log"]} + + +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__), + "properties": run_properties(), "corpus": run_corpus(), "table": run_table(), "resource": run_resource(), + "bounds": run_bounds(), "extra": run_extra(), "tokenizer": run_tokenizer_row()} +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..ee5b75825 --- /dev/null +++ b/tests/adapters/python/integration/logpoint-corpus/fuzz.py @@ -0,0 +1,165 @@ +"""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 + + +# Groups of every kind the check treats differently, and %-texts, for messages of two and three +# groups (the second review of stage 1: the sets above are one group each, and a rewrite's +# validation is about how groups and the template line up). Kinds: runs as is, fails alone and +# has an f-string form, holds two elements, starred, assigns, a display, a comment, a nested +# f-string, its own %. +MIXED_GROUPS = ["{x}", "{x!r}", "{total:.2f}", "{1, 2}", "{n, x}", "{*items}", "{x=}", "{y:=7}", + "{(y := 7)}", "{d['a:b']}", "{ {a, b} }", "{f'{x}'}", "{x # c\n}", "{lambda v: v}", + "{[i * 2 for i in items]}", "{'%s' % x}"] +MIXED_TEXTS = ["", " ", "%d ", "%s ", "%% ", "100% ", "%r ", "%5d ", "%(k)s ", "%*s "] + + +def mixed(): + """Every ordered pair of distinct groups after each text and between them, and every ordered + triple of the first ten after the first four texts: 7,680 messages.""" + out = [] + for t in MIXED_TEXTS: + for g1 in MIXED_GROUPS: + for g2 in MIXED_GROUPS: + if g1 != g2: + out += [t + g1 + " " + g2, g1 + " " + t + g2] + head = MIXED_GROUPS[:10] + for t in MIXED_TEXTS[:4]: + for g1 in head: + for g2 in head: + for g3 in head: + if len({g1, g2, g3}) == 3: + out.append(t + g1 + g2 + g3) + return out 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..9c27e712d --- /dev/null +++ b/tests/adapters/python/integration/logpoint-corpus/table.json @@ -0,0 +1,10689 @@ +{ + "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, 3.12.13 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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": " at 0x0000016FC3158720>" + }, + "3.13": { + "status": "runs", + "line": " at 0x\u2026>" + } + } + }, + { + "key": "row11", + "msg": "{y := 7}", + "expect": { + "3.11": { + "status": "runs", + "line": "7" + }, + "3.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": "{5}" + }, + "3.13": { + "status": "runs", + "line": "{5}" + } + } + }, + { + "key": "row14", + "msg": "{'a!r'}", + "expect": { + "3.11": { + "status": "runs", + "line": "a!r" + }, + "3.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": "{x!r}" + }, + "3.13": { + "status": "runs", + "line": "{x!r}" + } + } + }, + { + "key": "row18", + "msg": "{'{}'}", + "expect": { + "3.11": { + "status": "runs", + "line": "{}" + }, + "3.12": { + "status": "runs", + "line": "{}" + }, + "3.13": { + "status": "runs", + "line": "{}" + } + } + }, + { + "key": "row19", + "msg": "{'{:.2f}'.format(total)}", + "expect": { + "3.11": { + "status": "runs", + "line": "3.50" + }, + "3.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": "colon-key" + }, + "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.12": { + "status": "runs", + "line": "'colon-key'" + }, + "3.13": { + "status": "runs", + "line": "'colon-key'" + } + } + }, + { + "key": "row36", + "msg": "{f\"{{a:b}}\"}", + "expect": { + "3.11": { + "status": "runs", + "line": "{a:b}" + }, + "3.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": " at 0x0000016FC1D20D60>" + }, + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": " at 0x0000016FC1D21300>" + }, + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": " at 0x0000016FC1D214E0>" + }, + "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.12": { + "status": "runs", + "line": " at 0x0000016FC1D21800>" + }, + "3.13": { + "status": "runs", + "line": " at 0x\u2026>" + } + } + }, + { + "key": "row73", + "msg": "{(lambda *, kk=1: kk)()}", + "expect": { + "3.11": { + "status": "runs", + "line": "1" + }, + "3.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": " at 0x0000016FC1D222A0>" + }, + "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.12": { + "status": "runs", + "line": " at 0x0000016FC1D22480>" + }, + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": " at 0x0000016FC1D22980>" + }, + "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.12": { + "status": "runs", + "line": " at 0x0000016FC1D22B60>" + }, + "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.12": { + "status": "runs", + "line": " at 0x0000016FC1D22AC0>" + }, + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": "True" + }, + "3.13": { + "status": "runs", + "line": "True" + } + } + }, + { + "key": "row88", + "msg": "{total!=1}", + "expect": { + "3.11": { + "status": "runs", + "line": "True" + }, + "3.12": { + "status": "runs", + "line": "True" + }, + "3.13": { + "status": "runs", + "line": "True" + } + } + }, + { + "key": "row89", + "msg": "{a!=b!=x}", + "expect": { + "3.11": { + "status": "runs", + "line": "True" + }, + "3.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": "'L'" + }, + "3.13": { + "status": "runs", + "line": "'L'" + } + } + }, + { + "key": "row105", + "msg": "{minor}", + "expect": { + "3.11": { + "status": "runs", + "line": "3" + }, + "3.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "rewritten", + "wire": "{f'{0x1f:#x}'}", + "line": "0x1f" + }, + "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.12": { + "status": "runs", + "line": "0x1f" + }, + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": "caf\u00e9 at 0x0000016FC1D35A80>" + }, + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": "(1, slice(2, 3, None))" + }, + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": "" + }, + "3.13": { + "status": "runs", + "line": "" + } + } + }, + { + "key": "row133", + "msg": "{x.!r}", + "expect": { + "3.11": { + "status": "fails", + "line": "invalid syntax (, line 1)" + }, + "3.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "rewritten", + "wire": "{f'{n:#08x}'}", + "line": "0x0000ff" + }, + "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.12": { + "status": "runs", + "line": "0x0000ff" + }, + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "rewritten", + "wire": "{f'{ entry !r }'}", + "line": "'old'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{ entry !r }'}", + "line": "'old'" + } + } + }, + { + "key": "fix156", + "msg": "{repr(entry)}", + "expect": { + "3.11": { + "status": "runs", + "line": "'old'" + }, + "3.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "rewritten", + "wire": "{f'{x # c\n!r}'}", + "line": "'caf\u00e9'" + }, + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": "1" + }, + "3.13": { + "status": "runs", + "line": "1" + } + } + }, + { + "key": "row182", + "msg": "{land}", + "expect": { + "3.11": { + "status": "runs", + "line": "L" + }, + "3.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "rewritten", + "wire": "{f'{f\"{d[\"a:b\"]}\"!r}'}", + "line": "'colon-key'" + }, + "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.12": { + "status": "runs", + "line": "'colon-key'" + }, + "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.12": { + "status": "rewritten", + "wire": "{f'{f'{x # c\n}'!r}'}", + "line": "'caf\u00e9'" + }, + "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.12": { + "status": "runs", + "line": "'caf\u00e9'" + }, + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "rewritten", + "wire": "{f'{'a\\'b'!r}'}", + "line": "\"a'b\"" + }, + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "rewritten", + "wire": "{f'{f\"\\{x}\"!r}'}", + "line": "'\\\\caf\u00e9'" + }, + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "rewritten", + "wire": "{f'{b'\\x00'!r}'}", + "line": "b'\\x00'" + }, + "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.12": { + "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.12": { + "status": "rewritten", + "wire": "{f'{\"a\\\\\"!r}'}", + "line": "'a\\\\'" + }, + "3.13": { + "status": "rewritten", + "wire": "{f'{\"a\\\\\"!r}'}", + "line": "'a\\\\'" + } + } + }, + { + "key": "fix1026", + "msg": "{repr(\"a\\\\\")}", + "expect": { + "3.11": { + "status": "runs", + "line": "'a\\\\'" + }, + "3.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": " at 0x0000016FC1CCFD80>" + }, + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": "False" + }, + "3.13": { + "status": "runs", + "line": "False" + } + } + }, + { + "key": "row2021", + "msg": "{a <= b}", + "expect": { + "3.11": { + "status": "runs", + "line": "True" + }, + "3.12": { + "status": "runs", + "line": "True" + }, + "3.13": { + "status": "runs", + "line": "True" + } + } + }, + { + "key": "row2022", + "msg": "{a != b}", + "expect": { + "3.11": { + "status": "runs", + "line": "True" + }, + "3.12": { + "status": "runs", + "line": "True" + }, + "3.13": { + "status": "runs", + "line": "True" + } + } + }, + { + "key": "row2023", + "msg": "{a >= b}", + "expect": { + "3.11": { + "status": "runs", + "line": "False" + }, + "3.12": { + "status": "runs", + "line": "False" + }, + "3.13": { + "status": "runs", + "line": "False" + } + } + }, + { + "key": "row2024", + "msg": "{y := 5}", + "expect": { + "3.11": { + "status": "runs", + "line": "5" + }, + "3.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": "{'kk': at 0x0000016FC1D3A660>}" + }, + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": "'caf\u00e9' caf\u00e9 at 0x0000016FC1D6D4E0>" + }, + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "rewritten", + "wire": "{f'{(x # c\n)!r}'}", + "line": "'caf\u00e9'" + }, + "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.12": { + "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.12": { + "status": "runs", + "line": "colon-key" + }, + "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.12": { + "status": "runs", + "line": "colon-key" + }, + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "fails", + "line": "f-string: lambda expressions are not allowed without parentheses (, 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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": "{ at 0x0000016FC1D6F560>: '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.12": { + "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.12": { + "status": "runs", + "line": " at 0x0000016FC1D6F920>" + }, + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": "{'a:b': 'colon-key'}" + }, + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "rewritten", + "wire": "{f'{\"k\": 0x1f}'}", + "line": "Invalid format specifier ' 0x1f' 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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "rewritten", + "wire": "{f'{f\"\\{'\"'}\"!r}'}", + "line": "'\\\\\"'" + }, + "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.12": { + "status": "runs", + "line": "'\\\\\"'" + }, + "3.13": { + "status": "runs", + "line": "'\\\\\"'" + } + } + }, + { + "key": "row4009", + "msg": "{f'''{f\"{{\"}}}'''!r}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f\"\"\"{f'''{f\"{{\"}}}'''!r}\"\"\"}", + "line": "'{}'" + }, + "3.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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": "row5002", + "msg": "{\"k\": 1.}", + "expect": { + "3.11": { + "status": "rewritten", + "wire": "{f'{\"k\": 1.}'}", + "line": "Format specifier missing precision" + }, + "3.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "rewritten", + "wire": "{f'{\"k\": 0x1f.real}'}", + "line": "Invalid format specifier ' 0x1f.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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "rewritten", + "wire": "{f'{f\"{d[\"a:b\"]}\": total}'}", + "line": "Invalid format specifier ' total' for object of type 'str'" + }, + "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.12": { + "status": "runs", + "line": "{'colon-key': 3.5}" + }, + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "status": "runs", + "line": "{'a:b': 'vv'}" + }, + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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.12": { + "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/logpoint-pins.ts b/tests/adapters/python/integration/logpoint-pins.ts new file mode 100644 index 000000000..b5bfaae89 --- /dev/null +++ b/tests/adapters/python/integration/logpoint-pins.ts @@ -0,0 +1,81 @@ +/** + * The recorded lines of the logpoint corpus: pins, not the guarantee (issues + * #1334, #1349). + * + * What the check guarantees is asserted against the interpreter itself on any + * interpreter and debugpy (the properties in logpoint-corpus/emulate.py, and + * the live test's "what was sent is the checker's own wire"). What a hit logs, + * word for word, is CPython's wording, recorded per interpreter: a pin. + * + * - A pin is keyed by the Python minor version (`3.13`). Not by debugpy's: the + * conversion and its unbalanced-braces line are the same in debugpy 1.8.0, + * 1.8.20 and 1.8.22, and every other word a hit logs is CPython's (the pins + * pass on all three). Not by the patch version: the pins recorded on 3.12.13 + * pass on 3.12.3. What does depend on debugpy is not pinned: whether a live + * hit's assignment reaches the running function (on 3.12, debugpy 1.8.0 + * writes it back and 1.8.20 does not), so the live test asserts instead that + * every local a hit changed is one the verdict named; the recorded + * assignedAsWritten and assignedSent say what the recording's debugpy did. + * - An interpreter named explicitly (MCP_LOGPOINT_PYTHONS, as the workflow + * does) whose minor version has no pins is a failure: it was named to be + * checked. The machine's default interpreter without pins skips the pin + * tests, with a reason naming its version, and still runs the properties. + * - A row whose recorded lines depend on the platform rather than the text + * carries `linesDependOn` with the reason (gm-9: how deep the compiler can + * go at the hit is the C stack's, so 3.12 and 3.13 log a RecursionError on + * Windows and the sum on Linux). Its verdict and wire are pinned, its lines + * are not recorded or compared, and the properties hold it as any row. + * - MCP_LOGPOINT_RECORD=1 records pins instead of comparing them, for the + * interpreters named: the corpus test writes the verdicts and the emulated + * logs, the live test the live lines. Then run the same files without it. + */ +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { minorOf } from './logpoint-interpreters.js'; + +export const DATA = path.join(path.dirname(fileURLToPath(import.meta.url)), 'logpoint-corpus'); + +/** The interpreters were named (MCP_LOGPOINT_PYTHONS): one without pins is then a failure, not a skip. */ +export const interpretersNamed = Boolean(process.env.MCP_LOGPOINT_PYTHONS?.trim()); + +/** Recording pins instead of comparing them. */ +export const recordingPins = process.env.MCP_LOGPOINT_RECORD === '1'; + +/** The key a pin is recorded under for an interpreter version. */ +export const pinKeyOf = (version: string): string => minorOf(version); + +interface Pinned { rows: Array<{ expect: Record }> } + +/** Whether both data files hold pins for this key. */ +export function hasPins(key: string): boolean { + return ['corpus.json', 'table.json'].every((file) => { + const rows = (JSON.parse(fs.readFileSync(path.join(DATA, file), 'utf8')) as Pinned).rows; + return rows.length > 0 && rows.every((row) => row.expect[key] !== undefined); + }); +} + +/** Why the pin tests of an interpreter do not run, or undefined when they do. */ +export function pinsSkipReason(version: string): string | undefined { + if (recordingPins || hasPins(pinKeyOf(version))) return undefined; + return interpretersNamed + ? `no pins recorded for Python ${pinKeyOf(version)} (${version}, named explicitly: that is a failure, asserted on its own)` + : `no pins recorded for Python ${pinKeyOf(version)} (${version}, the machine's default interpreter): pins skipped, properties run`; +} + +/** `expect` with its keys in order, so a recorded version lands where a reader looks for it. */ +export function sortedExpect(expect: Record): Record { + return Object.fromEntries(Object.entries(expect).sort(([a], [b]) => a.localeCompare(b, 'en', { numeric: true }))); +} + +/** + * Rewrite one data file in place, keeping its shape (one-space indent, ASCII, + * no final newline): `update` changes its rows. + */ +export function updateDataFile(file: string, update: (data: T) => void): void { + const full = path.join(DATA, file); + const data = JSON.parse(fs.readFileSync(full, 'utf8')) as T; + update(data); + const text = JSON.stringify(data, null, 1).replace(/[^\x00-\x7e]/g, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, '0')}`); + fs.writeFileSync(full, text, 'utf8'); +} 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..d6fede7fc --- /dev/null +++ b/tests/adapters/python/integration/python-logpoint-corpus.test.ts @@ -0,0 +1,294 @@ +/** + * 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 message whose group's f-string form this interpreter's tokenizer cannot + * read (some 3.12 releases) is not checked, never failed; where the + * tokenizer reads it, it is rewritten; + * - 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. + * + * Two kinds of assertion. The guarantee, as properties of the interpreter + * itself, on any interpreter and debugpy, with no recorded line: per corpus and + * table row, the verdict and the wire against what the message as written and + * the wire do at pydevd's hit (emulate.py, run_properties); and the generated + * sets, the stated rows, the resource rows and the bounds above. And the pins: + * the recorded verdicts, wires and logs of the corpus and the table, per + * Python minor version (the f-string grammar changed in 3.12), compared only + * where recorded: logpoint-pins.ts has the rule. MCP_LOGPOINT_PYTHONS names + * the interpreters (see logpoint-interpreters.ts); MCP_LOGPOINT_RECORD=1 + * records the pins of the named ones instead of comparing them. + */ +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 { PYTHON_LOGPOINT_CHECKER_SOURCE } from '@debugmcp/shared'; +import { interpretersUnderTest, type InterpreterUnderTest } from './logpoint-interpreters.js'; +import { DATA, hasPins, interpretersNamed as named, pinKeyOf, pinsSkipReason, recordingPins, sortedExpect, updateDataFile } from './logpoint-pins.js'; + +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; +} +/** linesDependOn: why the row's lines are not pinned (they depend on the platform, not the text or the minor version). */ +interface CorpusRow { id: string; msg: string; linesDependOn?: 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 }>; + tokenizer: { tokenizerRaises: string[]; status: string; cause: string | null; wire: string | null; logA: string | null }; + properties: { counts: { corpus: Record; table: Record; mixed: Record }; violations: Record }; +} + +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 = pinKeyOf(interpreter.version!); + const skipPins = pinsSkipReason(interpreter.version!); + + beforeAll(() => { + result = emulate(interpreter); + console.log(`[logpoint corpus] Python ${result.python}, debugpy ${result.debugpy}: emulated in ${result.seconds} s`); + }, 900_000); + + it('emulates on this interpreter: debugpy imports and the checker loads', () => { + expect(result.error).toBeUndefined(); + }); + + it("holds the guarantee here, row by row: each verdict and wire against what the message and the wire do at pydevd's hit", () => { + expect(result.properties.violations).toEqual({}); + const total = (counts: Record) => Object.values(counts).reduce((a, b) => a + b, 0); + expect(total(result.properties.counts.corpus)).toBe(corpus.length); + expect(total(result.properties.counts.table)).toBe(table.length); + // The messages of two and three groups (fuzz.mixed): 7,680. + expect(total(result.properties.counts.mixed)).toBe(7680); + console.log(`[logpoint corpus] Python ${result.python}, debugpy ${result.debugpy} properties: ${JSON.stringify(result.properties.counts)}`); + }); + + it.skipIf(!named || recordingPins)(`has pins recorded for Python ${minor}: it was named to be checked`, () => { + expect(hasPins(minor), `no pins recorded for Python ${minor} (${interpreter.version}); record them with MCP_LOGPOINT_RECORD=1`).toBe(true); + }); + + // Registered only while recording: the workflow counts a skipped test as a job that proved nothing. + if (recordingPins) it(`records the pins of Python ${minor}: verdicts, wires and emulated logs`, () => { + updateDataFile<{ rows: CorpusRow[] }>('corpus.json', (data) => data.rows.forEach((row, index) => { + const got = result.corpus[index]; + expect(got.id).toBe(row.id); + const live = (row.expect[minor] as { live?: unknown } | undefined)?.live; + row.expect = sortedExpect({ ...row.expect, [minor]: { + status: got.verdict.status, + ...(got.verdict.wire !== undefined ? { wire: got.verdict.wire } : {}), + ...(got.verdict.assigns !== undefined ? { assigns: got.verdict.assigns } : {}), + ...(row.linesDependOn === undefined ? { envs: got.envs } : {}), + ...(live !== undefined ? { live } : {}) + } as Expectation }); + })); + updateDataFile<{ rows: TableRow[] }>('table.json', (data) => data.rows.forEach((row, index) => { + const got = result.table[index]; + expect(got.key).toBe(row.key); + row.expect = sortedExpect({ ...row.expect, [minor]: { + status: got.verdict.status, + ...(got.verdict.wire !== undefined ? { wire: got.verdict.wire } : {}), + line: row.expect[minor]?.line ?? null + } }); + })); + }); + + describe.skipIf(skipPins !== undefined || recordingPins)(`pins of Python ${minor}${skipPins ? ` (${skipPins})` : ''}`, () => { + it('gives every counterexample its recorded verdict, wire and logs, row by row (a row whose lines depend on the platform: its verdict and wire)', () => { + 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 }); + } + if (row.linesDependOn !== undefined) { + if (want.envs !== undefined) mismatches.push({ id: row.id, problem: 'lines pinned for a row whose lines depend on the platform' }); + return; + } + 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.slice(0, 3)).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('takes the delimiter as the tokenizer reads it: an escaped quote in a format spec is one literal, a group that would end the f-string and start another is not', () => { + const pep701 = Number(minor.split('.')[1]) >= 12; + expect(result.extra.slice(3, 5)).toEqual([ + // The same wire on every version: before PEP 701 too, an escaped delimiter in a format spec stays inside the literal. + { status: 'rewritten', wire: "{f'{x:\\'}'}", logA: expect.any(String) }, + // Not f'{{' f'{x + "}}"}' (two literals joined: `{` and the field): one literal holding the group's text. + { status: 'rewritten', wire: pep701 ? `{f"{{' f'{x + "}}"}"}` : `{f'''{{' f'{x + "}}"}'''}`, logA: "{' f'café}}" } + ]); + }); + + it('fails a group of two elements beside a rewritten one, and names a group whose f-string form does not compile', () => { + expect(result.extra.slice(5)).toEqual([ + // '%d %s %s' % (f'{x!r}', 1, 2,) would format with every element 1 and fail at every hit (%d gets a string): + // the arity check and the untouched-group check each refuse it. + { status: 'fails', wire: null, logA: expect.any(String), note: 'validation' }, + { status: 'fails', wire: null, logA: expect.any(String), group: '[v for v in (n := items)]!r' } + ]); + }); + + 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("does not check a message whose group's f-string form this tokenizer cannot read, and rewrites it where the tokenizer can", () => { + // emulate.py TOKENIZER_ROW: 3.12.13's tokenize raises on its form, 3.12.3's does not, so the + // row is held by what this interpreter's tokenizer does, which emulate.py reports. + const row = result.tokenizer; + if (row.tokenizerRaises.length > 0) { + console.log(`[logpoint corpus] Python ${result.python}: the tokenizer raises ${row.tokenizerRaises.join(', ')} on the tokenizer row's f-string form`); + expect(row).toEqual({ + tokenizerRaises: row.tokenizerRaises, + status: 'unchecked', + cause: `the tokenizer failed here (${row.tokenizerRaises[0]})`, + wire: null, + logA: expect.any(String) + }); + } else { + const q = Number(minor.split('.')[1]) >= 12 ? "'" : "'''"; + expect(row).toEqual({ + tokenizerRaises: [], + status: 'rewritten', + cause: null, + wire: `{f${q}{(lambda q=1:q)()or{1:2\n}!r}${q}}`, + logA: '1' + }); + } + }); + + 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..3bfaa7d23 --- /dev/null +++ b/tests/adapters/python/integration/python-logpoint-live.test.ts @@ -0,0 +1,357 @@ +/** + * 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. The rows go in launches of PER_LAUNCH + * logpoints, one fixture file each (MCP_LOGPOINT_PYTHONS, see + * logpoint-interpreters.ts, names the interpreters): one function per + * logpoint, each with fresh locals, called in order, and a marker logpoint + * after each call, so that each row's lines are the ones between two markers. + * + * On any interpreter, with nothing recorded (the guarantee through the + * server): what the adapter received for each row (`logMessageSent` in + * list_breakpoints, or the message itself) is the wire the checker gives on + * that same interpreter, asked directly; every row whose check has something + * to say is listed in the launch answer with that checker's verdict (and what + * was sent, for a rewrite), and a message that runs without assigning is not; + * and a local a corpus row's hit changed is one the check named in its + * verdict (whether the change reaches the running function depends on the + * interpreter and on how debugpy traces it, so that is not pinned). + * + * Where pins are recorded for the interpreter's minor version + * (logpoint-pins.ts has the rule), its own test: the line each row logged, + * except a row whose line depends on the platform (`linesDependOn`). + * MCP_LOGPOINT_RECORD=1 records them instead, with a second set of launches + * whose rows all go as written (the launch names its interpreter, which the + * check does not check) for the as-written lines of the rewritten corpus rows. + */ +import { afterAll, beforeAll, describe, expect, it } from 'vitest'; +import fs from 'node:fs'; +import os from 'node:os'; +import path from 'node:path'; +import { spawn } from 'node:child_process'; +import { PYTHON_LOGPOINT_CHECKER } from '@debugmcp/shared'; +import { startStdioClient, type ToolAnswer } from '../../../test-utils/helpers/mcp-stdio-client.js'; +import { interpretersUnderTest, type InterpreterUnderTest } from './logpoint-interpreters.js'; +import { DATA, hasPins, interpretersNamed, pinKeyOf, pinsSkipReason, recordingPins, sortedExpect, updateDataFile } from './logpoint-pins.js'; + +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; linesDependOn?: 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; + +/** + * Logpoints per launch. debugpy checks each breakpoint of a setBreakpoints by + * reading and compiling its whole file again (pydevd_api.py add_breakpoint + * calls `_get_code_lines(path)` per breakpoint; the same in 1.8.0, 1.8.20 and + * 1.8.22), so n logpoints in a file of n functions cost n squared: all 641 in + * one 2,600-line file took 16 to 21 s on a fast machine and more than the + * server's 30 s launch window on a two-core one. A hundred a launch take well + * under a second there. + */ +const PER_LAUNCH = 100; + +/** 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é'" }; +/** The marker logpoint's line text, after each case of a launch: what no case logs. */ +const MARK = (k: number) => `@@logpoint-case ${k}@@`; + +interface Case { + key: string; + row: Row; + msg: string; + corpus: boolean; + file: string; + line: number; +} +interface Fixture { file: string; after: string; markLine: number; cases: Case[] } + +/** A corpus row's message as the corpus means it (emulate.py corpus_message: DEEP3000 is 3,000 nested additions). */ +const messageOf = (row: Row): string => (row.msg === 'DEEP3000' ? `{${Array(3000).fill('1').join('+')}}` : row.msg); + +/** + * Whether a corpus row runs live on this key: as recorded for it, else where every recorded + * version ran it. A row whose lines depend on the platform records no lines, so no `live`: it + * runs on every key, for what is sent and what the launch answer says, its lines not compared. + */ +function liveRow(row: Row, key: string): boolean { + if (row.linesDependOn !== undefined) { + return true; + } + const recorded = Object.entries(row.expect).filter(([k]) => k !== key); + return row.expect[key] !== undefined && !recordingPins + ? Boolean(row.expect[key].live) + : recorded.length > 0 && recorded.every(([, e]) => e.live !== undefined); +} + +function fixturesFor(key: string, dir: string): Fixture[] { + const rows = [ + ...table.map((row) => ({ row, key: `table:${row.key}`, corpus: false })), + ...corpus.filter((row) => liveRow(row, key)).map((row) => ({ row, key: `corpus:${row.id}`, corpus: true })) + ]; + const fixtures: Fixture[] = []; + for (let start = 0; start < rows.length; start += PER_LAUNCH) { + const file = path.join(dir, `live_logpoints_${fixtures.length}.py`); + const lines = [...TABLE_HEADER, 'def _mark(k):', ' return k', '']; + const markLine = TABLE_HEADER.length + 2; + const cases: Case[] = []; + for (const r of rows.slice(start, start + PER_LAUNCH)) { + // One function per logpoint, on `return 0`; a corpus row's on the AFTER line before it, so + // the hit runs first and the line records what it changed. + lines.push(`def c${cases.length}():`, r.corpus ? CORPUS_LOCALS : TABLE_LOCALS); + if (r.corpus) { + lines.push(` AFTER['${r.key}'] = {${CORPUS_NAMES.map((n) => `'${n}': repr(${n})`).join(', ')}}`); + cases.push({ key: r.key, row: r.row, msg: messageOf(r.row), corpus: true, file, line: lines.length }); + lines.push(' return 0'); + } else { + lines.push(' return 0'); + cases.push({ key: r.key, row: r.row, msg: r.row.msg, corpus: false, file, line: lines.length }); + } + lines.push(''); + } + const after = file.replace(/\.py$/, '.after.json'); + lines.push('', "if __name__ == '__main__':", ...cases.map((_, k) => ` c${k}(); _mark(${k})`), + ` json.dump(AFTER, open(${JSON.stringify(after)}, 'w', encoding='utf-8'), ensure_ascii=True)`, + // debugpy drops logpoint lines still queued at exit (#1265). + ' time.sleep(1)', ''); + fs.writeFileSync(file, lines.join('\n'), 'utf8'); + fixtures.push({ file, after, markLine, cases }); + } + return fixtures; +} + +type OutputAnswer = ToolAnswer & { entries?: Array<{ category: string; output: string }>; hasMore?: boolean; nextSince?: number }; +type ListAnswer = ToolAnswer & { breakpoints: Array<{ file: string; line: number; logMessage?: string; logMessageSent?: string; logMessageCheck?: string }> }; +type LaunchAnswer = ToolAnswer & { data?: { logMessageChecks?: Array<{ file: string; line: number; logMessage: string; logMessageSent?: string; status: string }> } }; + +const normalize = (text: string): string => text.replace(/0x[0-9A-Fa-f]+/g, '0x…'); +const where = (file: string, line: number): string => `${path.resolve(file).toLowerCase()}:${line}`; + +/** Per case, in order: what the adapter received, the launch answer's note, the lines it logged, the tracked locals after its hit. */ +interface LiveRun { + sent: Array; + checks: Array<{ logMessageSent?: string; status: string } | undefined>; + segments: string[][]; + after: Array>; +} + +/** The checker's verdict for each message, its wire, and the names it says the sent form assigns, on this interpreter, asked the way the server asks. */ +async function checkerWires(interpreter: InterpreterUnderTest, messages: string[]): Promise> { + const child = spawn(interpreter.command, [...PYTHON_LOGPOINT_CHECKER.args], { stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true }); + let out = ''; + child.stdout.on('data', (chunk: Buffer) => { out += chunk.toString(); }); + child.stderr.on('data', () => {}); + const closed = new Promise((resolve) => child.on('close', () => resolve())); + for (const m of messages) child.stdin.write(JSON.stringify({ op: 'check', m }) + '\n'); + child.stdin.end(); + await closed; + const answers = out.split('\n').filter(Boolean).map((line) => JSON.parse(line) as { status?: string; wire?: string; assigns?: string[] }); + expect(answers).toHaveLength(messages.length); + return answers.map((answer, i) => ({ status: answer.status ?? '(none)', wire: answer.wire ?? messages[i], assigns: answer.assigns ?? [] })); +} + +/** Every fixture launched in turn, a session each, every logpoint set before its launch as written; `dapLaunchArgs` as given. */ +async function liveRun(interpreter: InterpreterUnderTest, fixtures: Fixture[], dapLaunchArgs?: Record): Promise { + const server = await startStdioClient({ name: 'python-logpoint-live', env: { PYTHON_PATH: interpreter.command }, callTimeoutMs: 300_000 }); + const run: LiveRun = { sent: [], checks: [], segments: [], after: [] }; + const started0 = Date.now(); + try { + for (const fixture of fixtures) { + await server.createSession('python', 'python-logpoint-live'); + for (const c of fixture.cases) { + const set = await server.call('set_breakpoint', { file: c.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(); + } + await server.call('set_breakpoint', { file: fixture.file, line: fixture.markLine, logMessage: '@@logpoint-case {k}@@' }); + const launch = await server.call('start_debugging', { scriptPath: fixture.file, ...(dapLaunchArgs ? { dapLaunchArgs } : {}) }); + 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 < 50; 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 sent = new Map(listed.breakpoints.map((bp) => [where(bp.file, bp.line), bp.logMessageSent ?? bp.logMessage])); + const checks = new Map((launch.data?.logMessageChecks ?? []).map((note) => [where(note.file, note.line), note])); + const after = JSON.parse(fs.readFileSync(fixture.after, 'utf8')) as Record>; + const logged = entries.filter((e) => e.category === 'stdout').map((e) => e.output).join('').split(/\r?\n/); + if (logged[logged.length - 1] === '') logged.pop(); + // Each case's lines are the ones before its marker. + const segments: string[][] = []; + let current: string[] = []; + for (const line of logged) { + if (line === MARK(segments.length)) { + segments.push(current); + current = []; + } else { + current.push(line); + } + } + expect(segments, `a marker for every case of ${path.basename(fixture.file)}, in order (the log begins: ${JSON.stringify(logged.slice(0, 6))})`).toHaveLength(fixture.cases.length); + expect(current, 'lines after the last case').toEqual([]); + fixture.cases.forEach((c, k) => { + run.sent.push(sent.get(where(c.file, c.line))); + run.checks.push(checks.get(where(c.file, c.line))); + run.segments.push(segments[k]); + run.after.push(after[c.key] ?? {}); + }); + await server.call('close_debug_session'); + server.sessionId = undefined; + } + } finally { + await server.close(); + } + console.log(`[logpoint live] Python ${interpreter.version}: ${run.sent.length} logpoints in ${fixtures.length} launches, ${Math.round((Date.now() - started0) / 1000)} s`); + return run; +} + +const changedLocals = (run: LiveRun, index: number): Record => + Object.fromEntries(Object.entries(run.after[index]).filter(([k, v]) => TRACKED[k] !== undefined && TRACKED[k] !== v)); + +describe.skipIf(runnable.length === 0)('Python logpoints live through the server, row by row @requires-python', () => { + describe.each(runnable.map((i) => [`${i.version} (debugpy ${i.debugpy})`, i] as const))('on Python %s', (_label, interpreter) => { + const key = pinKeyOf(interpreter.version!); + const skipPins = pinsSkipReason(interpreter.version!); + let scratch: string; + let fixtures: Fixture[]; + let cases: Case[]; + let run: LiveRun; + let verdicts: Array<{ status: string; wire: string; assigns: string[] }>; + + beforeAll(async () => { + scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'mcp-logpoint-live-')); + fixtures = fixturesFor(key, scratch); + cases = fixtures.flatMap((f) => f.cases); + run = await liveRun(interpreter, fixtures); + verdicts = await checkerWires(interpreter, cases.map((c) => c.msg)); + }, 900_000); + + afterAll(() => { + if (scratch) fs.rmSync(scratch, { recursive: true, force: true }); + }); + + it.skipIf(!interpretersNamed || recordingPins)(`has pins recorded for Python ${key}: it was named to be checked`, () => { + expect(hasPins(key), `no pins recorded for Python ${key} (${interpreter.version}); record them with MCP_LOGPOINT_RECORD=1`).toBe(true); + }); + + it('sends what the checker on this interpreter says, lists exactly the checks that have something to say, and names every local a hit changed', () => { + const mismatches: unknown[] = []; + cases.forEach((c, index) => { + const { status, wire, assigns } = verdicts[index]; + if (run.sent[index] !== wire) { + mismatches.push({ key: c.key, problem: "sent is not the checker's wire", want: wire, got: run.sent[index] }); + } + // The launch answer lists a logpoint if and only if its check has something to say: every + // verdict but a message that runs without assigning. A listed one carries the checker's + // verdict, and `logMessageSent` exactly when what was sent is not what was written. + const note = run.checks[index]; + const listed = !(status === 'runs' && assigns.length === 0); + const want = { status, logMessageSent: wire !== c.msg ? wire : undefined }; + if (listed && note === undefined) { + mismatches.push({ key: c.key, problem: 'launch answer omits a check that has something to say', want }); + } else if (!listed && note !== undefined) { + mismatches.push({ key: c.key, problem: 'launch answer lists a message that runs without assigning', got: note }); + } else if (note !== undefined && (note.status !== want.status || note.logMessageSent !== want.logMessageSent)) { + mismatches.push({ key: c.key, problem: 'launch answer', want, got: { status: note.status, logMessageSent: note.logMessageSent } }); + } + // Whether a hit's assignment reaches the running function is the interpreter's and debugpy's + // (3.13 always; 3.12 with debugpy 1.8.0, not with 1.8.20): that the answer named it is the guarantee. + if (c.corpus) { + const unnamed = Object.keys(changedLocals(run, index)).filter((name) => !assigns.includes(name)); + if (unnamed.length > 0) { + mismatches.push({ key: c.key, problem: 'the hit assigned a local the check did not name', got: unnamed, assigns }); + } + } + }); + expect(mismatches).toEqual([]); + }); + + describe.skipIf(skipPins !== undefined || recordingPins)(`pins of Python ${key}${skipPins ? ` (${skipPins})` : ''}`, () => { + it('sends and logs what was recorded, row by row (a row whose line depends on the platform: what was sent only)', () => { + // (The recorded assignedAsWritten and assignedSent say what the recording's debugpy did; not compared, see above.) + const pinned: unknown[] = []; + cases.forEach((c, index) => { + const want = c.row.expect[key]; + if (want === undefined) { + pinned.push({ key: c.key, problem: `no pin recorded for Python ${key}` }); + return; + } + if ((want.wire ?? c.msg) !== run.sent[index]) { + pinned.push({ key: c.key, problem: 'sent', want: want.wire ?? c.msg, got: run.sent[index] }); + } + if (c.row.linesDependOn !== undefined) return; + const wantLines = c.corpus ? (want.wire !== undefined ? want.live!.sent : want.live!.asWritten) : want.line; + const lines = wantLines === null || wantLines === undefined ? [] : wantLines.split('\n'); + if (JSON.stringify(run.segments[index].map(normalize)) !== JSON.stringify(lines.map(normalize))) { + pinned.push({ key: c.key, problem: 'logged', want: lines, got: run.segments[index] }); + } + }); + expect(pinned).toEqual([]); + }); + }); + + // Registered only while recording: the workflow counts a skipped test as a job that proved nothing. + if (recordingPins) { + it(`records the live lines of Python ${key}`, async () => { + // The as-written lines of what was rewritten: a launch that names its interpreter is not checked. + const rewritten = cases.some((c, index) => c.corpus && verdicts[index].wire !== c.msg); + const asWritten = rewritten ? await liveRun(interpreter, fixtures, { python: interpreter.executable ?? interpreter.command }) : undefined; + const joined = (lines: string[]): string | null => (lines.length === 0 ? null : lines.join('\n')); + const indexOf = new Map(cases.map((c, index) => [c.key, index])); + // The corpus test records the verdicts first (MCP_LOGPOINT_RECORD=1, that file before this one). + updateDataFile<{ rows: Row[] }>('table.json', (data) => data.rows.forEach((row) => { + const index = indexOf.get(`table:${row.key}`)!; + expect(row.expect[key], `the corpus test has not recorded Python ${key} yet`).toBeDefined(); + row.expect = sortedExpect({ ...row.expect, [key]: { ...row.expect[key], line: row.linesDependOn ? null : joined(run.segments[index]) } }); + })); + updateDataFile<{ rows: Row[] }>('corpus.json', (data) => data.rows.forEach((row) => { + const index = indexOf.get(`corpus:${row.id}`); + if (index === undefined || row.expect[key] === undefined || row.linesDependOn !== undefined) return; + const assigned = changedLocals(run, index); + const live: LiveExpect = verdicts[index].wire === row.msg + ? { asWritten: joined(run.segments[index]), ...(Object.keys(assigned).length ? { assignedAsWritten: assigned } : {}) } + : { + asWritten: joined(asWritten!.segments[index]), + sent: joined(run.segments[index]), + ...(Object.keys(changedLocals(asWritten!, index)).length ? { assignedAsWritten: changedLocals(asWritten!, index) } : {}), + ...(Object.keys(assigned).length ? { assignedSent: assigned } : {}) + }; + row.expect = sortedExpect({ ...row.expect, [key]: { ...row.expect[key], live } }); + })); + }, 900_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..edf831a55 --- /dev/null +++ b/tests/adapters/python/integration/python-logpoint-paths.test.ts @@ -0,0 +1,410 @@ +/** + * 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, 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":', + ' print("LOGPOINT_FIXTURE_READY", flush=True)', + ' 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: `--