From fb5eec56dd2212d07a77dfb4ed4b25d26ccebcb2 Mon Sep 17 00:00:00 2001 From: G30 <50341825+silentoplayz@users.noreply.github.com> Date: Tue, 20 Oct 2026 13:22:24 -0400 Subject: [PATCH] fix: running a block whose last value is a date, Decimal or object shows the value instead of an error (#32682) --- src/lib/pyodide/pyodideSandboxHost.ts | 5 ++++- src/lib/workers/pyodide.worker.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/pyodide/pyodideSandboxHost.ts b/src/lib/pyodide/pyodideSandboxHost.ts index b99ac0fc71..3f64927159 100644 --- a/src/lib/pyodide/pyodideSandboxHost.ts +++ b/src/lib/pyodide/pyodideSandboxHost.ts @@ -92,7 +92,10 @@ const sandboxScript = String.raw` if (['string', 'number', 'boolean'].includes(typeof value)) return value; if (typeof value === 'bigint') return value.toString(); if (Array.isArray(value)) return value.map(clean); - if (typeof value.toJs === 'function') return clean(value.toJs()); + if (typeof value.toJs === 'function') { + const converted = value.toJs(); + return typeof converted?.toJs === 'function' ? converted.toString() : clean(converted); + } if (typeof value === 'object') { const out = {}; for (const key in value) { diff --git a/src/lib/workers/pyodide.worker.ts b/src/lib/workers/pyodide.worker.ts index 4eb3ee7a31..9318d15425 100644 --- a/src/lib/workers/pyodide.worker.ts +++ b/src/lib/workers/pyodide.worker.ts @@ -346,7 +346,10 @@ function processResult(result: any): any { } if (typeof result.toJs === 'function') { // If it's a Pyodide proxy object (e.g., Pandas DF, Numpy Array), convert to JS and process recursively - return processResult(result.toJs()); + const converted = result.toJs(); + return typeof converted?.toJs === 'function' + ? converted.toString() + : processResult(converted); } if (typeof result === 'object') { // Convert JS objects to a recursively serialized representation