Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions packages/cli/tests/workerd-test/entropy-patches/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ async def noop(*args):

class Default(WorkerEntrypoint):
async def test(self):
if sys.version_info >= (3, 14):
# FIXME(soon): fix entropy patches for newer packages
return

os.chdir("/session/metadata/tests")
args = [".", "-vv"]
assert pytest.main(args) == 0
22 changes: 15 additions & 7 deletions packages/runtime-sdk/src/_workers_sdk_entropy_import_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,22 @@ def pydantic_core_context(module):
with allow_bad_entropy_calls(1):
yield
finally:
try:
validate_core_schema = getattr(module, "validate_core_schema", None)
if validate_core_schema is None:
# pydantic-core >=2.41 no longer exports validate_core_schema. Build a
# tiny validator instead so any lazy hash-map seeds are initialized
Comment on lines +97 to +98

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
# pydantic-core >=2.41 no longer exports validate_core_schema. Build a
# tiny validator instead so any lazy hash-map seeds are initialized
# Build a tiny validator instead so any lazy hash-map seeds are initialized

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we just delete the other branch? This should work always.

# before the snapshot is captured.
with allow_bad_entropy_calls(1):
# validate_core_schema makes an ahash::AHashMap which makes
# another entropy call for its hash seed. It will throw an error
# but only after making the needed entropy call.
module.validate_core_schema(None)
except module.SchemaError:
pass
module.SchemaValidator({"type": "any"})
else:
try:
with allow_bad_entropy_calls(1):
# validate_core_schema makes an ahash::AHashMap which makes
# another entropy call for its hash seed. It will throw an error
# but only after making the needed entropy call.
validate_core_schema(None)
except module.SchemaError:
pass


@register_exec_patch("aiohttp.http_websocket")
Expand Down
Loading