fix(code-runtime-python): capture the error-class constructor and dispatch primitives

The review's remaining items:
- _make_error_class captures Exception and setattr as def-time defaults, so a
  rebind of __main__.Exception/__main__.setattr cannot break the rejection
  constructor.
- dispatch binds _lossless_json_violation, asyncio.get_event_loop, and the
  channel's send method into _run locals before the program runs, so a rebind
  cannot turn a legitimate binding call into an exception or a wall-clock
  timeout.
- The note (en + zh) corrects the stdin coverage phrasing: d3f9f57f5's direct
  EOF-observing case is the in-tree pin, not an approximation.
- Collapse two stray double blank lines in the test file.
Pairing re-recorded.
This commit is contained in:
Chinesezjc
2026-08-31 14:49:54 +08:00
committed by Tianyi Cui
parent c4d6c25ffc
commit 6a659df999
5 changed files with 28 additions and 12 deletions
@@ -750,7 +750,6 @@ describe('PythonCodeRuntime — programs and bindings', () => {
expect(result.value).toBe('nope')
}, 15_000)
it('still answers the call when the rejection value cannot be converted to a string', async () => {
// `messageOf` calls `String(error)`, which runs the value's own conversion,
// and this call site is a DETACHED async reply callback. A rejection whose
@@ -4297,7 +4296,6 @@ describe('PythonCodeRuntime — hostile peer', () => {
expect(result.value).toBe(8 * chunk.length)
}, 90_000)
it('bounds a flood of zero-byte log lines through the per-entry separator charge', async () => {
// Blank print() lines carry zero content bytes; without the +1 separator
// charge they would bypass maxLogBytes entirely and grow the retained