• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

source-academy / py-slang / 31163103731
86%

Build:
DEFAULT BRANCH: main
Ran 07 Aug 2026 09:06AM UTC
Jobs 1
Files 138
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

07 Aug 2026 08:46AM UTC coverage: 86.219% (-0.003%) from 86.222%
31163103731

push

github

web-flow
Py2JS: a module-level name falls back to its builtin before assignment (#420)

py-slang#415: `print(1)` followed later by `def print(x): return x`
raised a NameError on the *first* `print(1)` call -- even though it
runs before the redefinition ever executes -- instead of using the
real builtin, as CPython (and the substitution stepper) both do.
CPython resolves a module-level name dynamically at the point of each
read: globals() first, then builtins(), never decided statically
ahead of time.

compileProgram's builtin preamble (compiler.ts) already skips
generating a hoisted `const $name = __py.builtins[name]` binding for
any name the chunk itself assigns anywhere at module level, so a
later read (once that assignment has actually run) correctly sees the
local binding. But an *earlier* read -- before the assignment runs --
had nothing left to fall back to: runtime.ts's gref (REPL mode) and
the inline `programGlobals` read compiler.ts emits (program mode)
both went straight to NameError the moment the chunk's own binding
was still undefined, with no builtin fallback at all.

gref now falls back to `this.builtins[name]`, mirroring CPython's own
lookup order. The program-mode path needed the identical fallback
somewhere else, since its "current value" is a hoisted `let` read
inline rather than an indexed globals-table lookup -- new `pgref`
factors out the shared fallback logic and emitName's programGlobals
branch now calls it instead of nameErr directly.


Claude-Session: https://claude.ai/code/session_019GKx36me2L9FrkDhqvHJ6X

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>

4803 of 6008 branches covered (79.94%)

Branch coverage included in aggregate %.

5 of 7 new or added lines in 2 files covered. (71.43%)

10725 of 12002 relevant lines covered (89.36%)

164452.11 hits per line

Uncovered Changes

Lines Coverage ∆ File
1
89.63
0.0% src/engines/py2js/compiler.ts
1
86.65
-0.09% src/engines/py2js/runtime.ts
Jobs
ID Job ID Ran Files Coverage
1 31163103731.1 07 Aug 2026 09:06AM UTC 138
86.22
GitHub Action Run
Source Files on build 31163103731
  • Tree
  • List 138
  • Changed 2
  • Source Changed 2
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #31163103731
  • 418a6f4d on github
  • Prev Build on main (#31160943792)
  • Next Build on main (#31165450514)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc