Implement `os.path`
Summary by cubic
Implements os.path (also importable as posixpath) as a module reached through os. Pure functions like join, split, normpath, and relpath run the posixpath algorithms on bytes so str, bytes, and pathlib.Path share one code path; host-backed functions like exists, isfile, getsize, lexists, samefile, realpath (including strict=True), and expanduser reuse existing Path/os host calls, chaining a second call where a function needs one. The path model is always POSIX regardless of host OS. Vendors upstream posixpath/genericpath stubs, with os/path.pyi pinning os.path to posixpath. expandvars charges its output growth to the memory budget: each capacity doubling is preflighted, so amplifying substitutions raise MemoryError at the soft limit instead of building the whole result.
os.stat, os.listdir, os.chdir, and the os.path functions built on them now accept int paths and fail them as closed file descriptors, matching CPython: OSError EBADF, False from the predicates, and OverflowError outside C int.
Hosts must now answer the extra chained calls (one OsCall at a time follows the reply); no other host changes are needed.
Bug fixes
import a.bnow loadsa.bbut bindsalike CPython; aliased imports still bind the submodule. Failed dotted imports name the first missing component, or the module that is not a package.- Heap-allocated bytes now compare and order like literals.
commonprefixreturns the smallest element itself instead of a copy.
Limitations
sameopenfileis not implemented: it needs a host call no existing call provides.ismountreports every existing path as a mount point, since the sandbox cannot see the host's mount layout.- Host-backed functions take
str/PathLike[str]only, with nobytespaths; ints fail as closed descriptors rather than reaching real fds. Documented indocs/limitations/os.md.