Set custom path with `run_code`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.2k
- Forks
- 1k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 66
Description
Hello!
I was wondering if it might be possible to add a path parameter to run_code, so that it could create a code objection a different path than the default of "<string>\0". It could be an optional parameter that defaults to the current value. Alternatively, to not break the API, maybe another function called run_code_path could be created that is also public that run_code calls with that parameter?
Currently, I am keeping a duplicate of that function in my source with the parameter added, which adds some overhead when changes happen upstream.
I am doing arbitrary code execution, but I want the tracebacks to refer to line numbers that can be referenced, so I am creating a temporary file, writing the code to it, then evaling that code with that path:
I am happy to make a PR to add this feature if it is desired. Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the public run_code entry point and trace how it creates code objects, using the linked src/py_object_sort.rs implementation as context for the requested path behavior. Confirm that the optional path preserves the current default and that supplied paths appear in traceback filenames.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100