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

bpo-36375: PEP 499 implementation: "python -m foo" binds the main module as both __main__ and foo in sys.modules #12490

Closed
wants to merge 10 commits into from

Conversation

cameron-simpson
Copy link

@cameron-simpson cameron-simpson commented Mar 22, 2019

This contains documentation updates, runpy.py implementation, two unit tests and a fix for Lib/pdb.py to accomodate new aliasing of __main__ as the module's canonical name.

A run of "make test" on my El Capitan Mac here now shows the following failures:

test_c_locale_coercion test_smtpnet test_ssl test_urllib
test_urllib2 test_urllib2net test_xmlrpc

Of these:

test_c_locale_coercion appears to be due to differences between my OS release and presumably more modern Darwin releases: various "utf-8" vs "ascii" mismatches in the output.

text_xmlrpc seems to run forever, here

the other tests fail for network based reasons.

WRT to a run against the master branch, the failure set is the same.

I cannot reproduce the hashlib based failures seen by Travis on my earlier PR. It will be interesting to see what Travis says now.

https://bugs.python.org/issue36375

Copy link
Contributor

@ncoghlan ncoghlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just adding a blocking review to ensure the PR isn't merged until after the PEP has been reviewed.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@@ -1531,8 1532,7 @@ def _runmodule(self, module_name):
import runpy
mod_name, mod_spec, code = runpy._get_module_details(module_name)
self.mainpyfile = self.canonic(code.co_filename)
import __main__
__main__.__dict__.clear()
__main__ = types.ModuleType(module_name, 'New __main__ module for pdb.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't interact correctly with the interpreter's -i switch, as that always drops you into the original __main__ namespace, even if it's been rebound in sys.modules by the application code.

@ncoghlan
Copy link
Contributor

@cameron-simpson This is looking pretty good, but there are still some backwards compatibility risks that we're going to have to investigate before the PEP can be approved.

I'm officially the design & implementation reviewer for this PEP now, so I added the two key questions/concerns that I'm currently aware of to a new section: python/peps#946

@erlend-aasland
Copy link
Contributor

Closing this, as the linked issue has been closed.

@erlend-aasland erlend-aasland removed the pending The issue will be closed if no feedback is provided label Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants