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
"pdb -m <module>" sets __main__.__package__ incorrectly #76872
Comments
For regular modules, the initial implementation of bpo-32206 sets __package__ to "module_name" instead of "module_name.rpartition('.')[0]". This is not correct, and will cause problems for relative imports. |
In the backport, I found that |
OK, just managed to reproduce it. This appears only when you run a python script as a module. Running a module with __main__ does not show the issue. Will get a patch ready |
I forget we had mod_spec.parent available to us these days, so yes, we should use that rather than recalculating the parent with str.rpartition. As Mario noted, we only want to change the behaviour when the executed module is a plain module or submodule, rather than being a package in its own right with a pkg.__main__ submodule (since the current behaviour is correct in the latter case). |
Sent a PR for the fix. I'll update PRs for trace. profile does not need it Thanks a lot for bringing it up Jason! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: