Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SEEK_END for Python metadatafs #3384

Merged
merged 1 commit into from
Jan 22, 2025
Merged
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: 2 additions & 2 deletions src/pyodide/internal/readOnlyFS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ export function createReadonlyFS<Info>(
} else if (whence === 2) {
// SEEK_END
if (FS.isFile(stream.node.mode)) {
if ((stream.node.info as any).size == undefined) {
if (stream.node.usedBytes == undefined) {
throw new Error('File size is undefined');
}
position += (stream.node.info as any).size;
position += stream.node.usedBytes;
}
}
return position;
Expand Down
4 changes: 2 additions & 2 deletions src/workerd/io/compatibility-date.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ struct CompatibilityFlags @0x8f8c1b68151b6cef {
pythonWorkers @43 :Bool
$compatEnableFlag("python_workers")
$pythonSnapshotRelease(pyodide = "0.26.0a2", pyodideRevision = "2024-03-01",
packages = "20240829.4", backport = 13,
packages = "20240829.4", backport = 14,
baselineSnapshotHash = "d13ce2f4a0ade2e09047b469874dacf4d071ed3558fec4c26f8d0b99d95f77b5")
$impliedByAfterDate(name = "pythonWorkersDevPyodide", date = "2000-01-01");
# Enables Python Workers. Access to this flag is not restricted, instead bundles containing
Expand Down Expand Up @@ -684,7 +684,7 @@ struct CompatibilityFlags @0x8f8c1b68151b6cef {
$compatEnableFlag("python_workers_20250116")
$experimental
$pythonSnapshotRelease(pyodide = "0.27.1", pyodideRevision = "2025-01-16",
packages = "20241218", backport = 0,
packages = "20241218", backport = 2,
baselineSnapshotHash = "TODO");

requestCfOverridesCacheRules @72 :Bool
Expand Down
2 changes: 2 additions & 0 deletions src/workerd/server/tests/python/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ py_wd_test(
],
)

py_wd_test("seek-metadatafs")

gen_import_tests(
PYODIDE_IMPORTS_TO_TEST,
# TODO: Micropip version mismatch for 0.27.0
Expand Down
8 changes: 8 additions & 0 deletions src/workerd/server/tests/python/seek-metadatafs/a.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import os
from pathlib import Path


def test():
fh = Path(__file__).open()
print(fh.fileno())
print(f"This file is {os.lseek(fh.fileno(), 0, os.SEEK_END)} characters long")
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Workerd = import "/workerd/workerd.capnp";

const unitTests :Workerd.Config = (
services = [
( name = "main",
worker = (
modules = [
(name = "a.py", pythonModule = embed "./a.py"),
],
compatibilityDate = "2023-12-18",
compatibilityFlags = [%PYTHON_FEATURE_FLAGS],
)
),
],
);

Loading