python-wasm
python-wasm copied to clipboard
NODERAWFS: fstat() of unlinked file fails
Emscripten's fstat() fails with FileNotFoundError when the underlying file has been unlinked. The behavior breaks a handful of test cases.
import os
f = open("testfile", "w+")
f.write("test")
f.seek(0)
print(os.fstat(f.fileno()))
os.unlink(f.name)
print(f.read())
print(os.fstat(f.fileno()))
$ python test_fstat.py
os.stat_result(st_mode=33206, st_ino=10374816, st_dev=91, st_nlink=1, st_uid=0, st_gid=0, st_size=4, st_atime=1646767083, st_mtime=1646767083, st_ctime=1646767083)
test
os.stat_result(st_mode=33206, st_ino=10374816, st_dev=91, st_nlink=0, st_uid=0, st_gid=0, st_size=4, st_atime=1646767083, st_mtime=1646767083, st_ctime=1646767083)
$ ./run-python-node.sh fst.py
os.stat_result(st_mode=33206, st_ino=10374816, st_dev=91, st_nlink=1, st_uid=0, st_gid=0, st_size=4, st_atime=1646765917, st_mtime=1646765917, st_ctime=1646765917)
test
Traceback (most recent call last):
File "/python-wasm/fst.py", line 9, in <module>
print(os.fstat(f.fileno()))
^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 44] No such file or directory