From 9e6f279040446496c5886d059ad8973aede2f80d Mon Sep 17 00:00:00 2001 From: Chinesezjc Date: Thu, 20 Aug 2026 12:21:17 +0800 Subject: [PATCH] fix(code-runtime-python): drop the sealed-blocks ternary in the stray flush to hold 100% branch coverage --- packages/code-runtime/code-runtime-python/src/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/code-runtime/code-runtime-python/src/index.ts b/packages/code-runtime/code-runtime-python/src/index.ts index 4faf524bcd..abcc0a0efa 100644 --- a/packages/code-runtime/code-runtime-python/src/index.ts +++ b/packages/code-runtime/code-runtime-python/src/index.ts @@ -1134,8 +1134,11 @@ export class PythonCodeRuntime extends CodeRuntime { // sequence is real truncated input and the U+FFFD is the honest render. function flushStray(stray: StrayBuffer, retainPartialTail?: boolean): void { if (stray.chunks.length === 0 && stray.blocks.length === 0) return - const begun = stray.blocks.length > 0 ? [...stray.blocks, ...stray.chunks] : stray.chunks - let full = Buffer.concat(begun) + // Concatenate the sealed blocks and the current-chunk residual together + // unconditionally (no `blocks.length > 0` ternary): a flush can run with + // either or both present, and a branch on their presence would need a + // test that flushes exactly at a seal boundary. + let full = Buffer.concat([...stray.blocks, ...stray.chunks]) // A budget flush landing exactly between a lead byte and its // still-pending continuation requires the combined-cost threshold to trip // on a specific mid-multibyte pipe boundary — not deterministically