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

py.run: __name__ is "builtins", should be "__main__" #4928

Open
nschloe opened this issue Feb 22, 2025 · 0 comments
Open

py.run: __name__ is "builtins", should be "__main__" #4928

nschloe opened this issue Feb 22, 2025 · 0 comments
Labels

Comments

@nschloe
Copy link

nschloe commented Feb 22, 2025

Bug Description

Python's exec() has __name__ set to __main__:

exec("print(__name__)")
__main__

When running the same code through PyO3's py.run(), it'll give builtins.

Steps to Reproduce

See above.

Backtrace

Your operating system and version

Linux 6.12.13-1-lts

Your Python version (python --version)

Python 3.11.11

Your Rust version (rustc --version)

rustc 1.85.0 (4d91de4e4 2025-02-17) (Arch Linux rust 1:1.85.0-1)

Your PyO3 version

v0.23.4

How did you install python? Did you use a virtualenv?

uv venv

Additional Info

No response

@nschloe nschloe added the bug label Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant