Skip to content

Let registerPythonCommonModules() take a ModuleSource - #8542

Merged
erikcorry merged 1 commit into
mainfrom
erikcorry/python-modules-source
Nov 18, 2026
Merged

erikcorry merged 1 commit into
mainfrom
erikcorry/python-modules-source

Conversation

@erikcorry

Copy link
Copy Markdown
Contributor

PYODIDE_BUNDLE is the one compiled-in bundle that was still registered without the jsg::ModuleSource the other bundles accept, so an embedder with its own storage for module sources could not serve the Python builtins from it. Thread the parameter through to addBuiltinBundle(), defaulting to nullptr as elsewhere.

PyodideBundleManager::setPyodideBundleData() takes the bundle as kj::Array: the manager only reads it, and the bytes may come from read-only storage.

PYODIDE_BUNDLE is the one compiled-in bundle that was still
registered without the jsg::ModuleSource the other bundles accept,
so an embedder with its own storage for module sources could not
serve the Python builtins from it. Thread the parameter through to
addBuiltinBundle(), defaulting to nullptr as elsewhere.

PyodideBundleManager::setPyodideBundleData() takes the bundle as
kj::Array<const kj::byte>: the manager only reads it, and the bytes
may come from read-only storage.
@erikcorry
erikcorry requested review from a team as code owners November 17, 2026 14:58

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved — A small change that threads an optional parameter through and keeps existing behaviour, plus a const-correctness fix to a signature. No issues found.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

📋 Code Quality: ✅ LGTM

moduleSource is passed to the matching addBuiltinBundle overload. A null value keeps the previous behaviour, and existing callers are unaffected because the new trailing parameter has a default. Changing setPyodideBundleData to take kj::Array<const kj::byte> is correct: the data is only read, and both callers pass rvalue kj::Array<kj::byte>, which converts implicitly.


📝 Documentation: ✅ LGTM

The new comments in pyodide.h and worker-modules.h accurately describe the lifetime and storage requirements for the bundle data and the module source.


Reviewed commit: 65427a64

@jasnell
jasnell requested review from dom96 and hoodmane November 17, 2026 17:18
@erikcorry
erikcorry merged commit bb08e38 into main Nov 18, 2026
23 of 24 checks passed
@erikcorry
erikcorry deleted the erikcorry/python-modules-source branch November 18, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants