[issue37941] python -m and runpy.run_module set different __name__ by default

2019-09-12 Thread Julian Berman
Julian Berman added the comment: That all makes sense, I understand that in the general case you can't really promise someone that if you mutate global state in-process that the runpy module has any way of preventing that. Except IMO, the module gives exactly the impression you're saying is

[issue37941] python -m and runpy.run_module set different __name__ by default

2019-09-11 Thread Nick Coghlan
Nick Coghlan added the comment: There is one, it just isn't public: runpy._run_module_as_main. It's a private API that the -m switch implementation calls, and was introduced after the original runpy.run_module was found not to offer everything the switch needed. It isn't possible to fully

[issue37941] python -m and runpy.run_module set different __name__ by default

2019-09-03 Thread Julian Berman
Julian Berman added the comment: Is there no desire to have an API that works like -m (entirely. In this and any other way)? On Tue, Sep 3, 2019, 09:41 Nick Coghlan wrote: > > Change by Nick Coghlan : > > > -- > stage: -> resolved > status: open -> closed > >

[issue37941] python -m and runpy.run_module set different __name__ by default

2019-09-03 Thread Nick Coghlan
Nick Coghlan added the comment: Yes, this is deliberate. From the run_module documentation: "__name__ is set to run_name if this optional argument is not None, to mod_name + '.__main__' if the named module is a package and to the mod_name argument otherwise." This allows arbitrary code to

[issue37941] python -m and runpy.run_module set different __name__ by default

2019-09-03 Thread Nick Coghlan
Change by Nick Coghlan : -- stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue37941] python -m and runpy.run_module set different __name__ by default

2019-08-26 Thread Brett Cannon
Change by Brett Cannon : -- nosy: +ncoghlan ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue37941] python -m and runpy.run_module set different __name__ by default

2019-08-24 Thread Julian Berman
New submission from Julian Berman : This seems brutally simple, to the point where I'm concerned I'm missing something (or have seen this issue filed elsewhere but can't find it), but `python -m` and `runpy.run_module` don't set the same __name__ -- specifically `runpy.run_module`, when