-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Problem
When Python code accesses os module functions/attributes, the transpiled Rust generates references to an undefined os value:
import os
path = os.path.join("a", "b") # E0425: cannot find value `os` in this scope
cwd = os.getcwd() # E0425: cannot find value `os` in this scopeImpact
16 files in the reprorusted-python-cli corpus fail due to this issue.
Suggested Fix
Map common os module functions to Rust equivalents:
| Python | Rust |
|---|---|
os.getcwd() |
std::env::current_dir() |
os.path.join(a, b) |
std::path::Path::new(a).join(b) |
os.path.exists(p) |
std::path::Path::new(p).exists() |
os.path.dirname(p) |
std::path::Path::new(p).parent() |
os.path.basename(p) |
std::path::Path::new(p).file_name() |
os.environ.get(k) |
std::env::var(k) |
os.listdir(p) |
std::fs::read_dir(p) |
Corpus Evidence
From reprorusted-python-cli error analysis:
- E0425 (cannot find value) accounts for 10.0% of all compilation errors
- 16 examples specifically fail on
osmodule access
Related
- Part of single-shot compile rate improvement effort (Track Single-Shot Compile Rate (Transpile → cargo check) #193)
- Release gate: 80% single-shot (RELEASE GATE: 80% Single-Shot Compile Rate #194)
- Previously identified in roadmap feat: Map os module to std::env/std::fs #196
Metadata
Metadata
Assignees
Labels
No labels