Commit 2bdddc6
Florian Standhartinger
kernel: don't let the workspace shadow the stdlib
Found by running the real binary for the first time. The run happened to
be in /tmp, which contained a stray inspect.py, and the kernel never
booted — 'python -m' prepends the cwd to sys.path, so that file shadowed
the stdlib module that dataclasses imports.
This is not an edge case for a coding agent. It works inside other
people's repositories, and those are full of files called types.py,
token.py, code.py and parser.py. Any one of them would have taken the
kernel down on that repo and nowhere else.
Two changes: the kernel now starts in the workspace via current_dir, so
relative paths in a cell mean what the model expects; and PYTHONSAFEPATH
keeps that directory off sys.path.
The regression test plants inspect.py, types.py and token.py in the
workspace. It fails without the fix — verified, not assumed.
Worth noting the model diagnosed this correctly and unaided from the
traceback we surface, named the shadowing file, and offered three fixes.
The error path works.1 parent 86dba36 commit 2bdddc6
2 files changed
Lines changed: 43 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
143 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
144 | 157 | | |
145 | 158 | | |
146 | 159 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
0 commit comments