This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mikekap
Recipients eric.snow, mikekap, ncoghlan
Date 2016-10-23.22:42:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Hey Nick,

Sorry for the long delay. Unfortunately Python isn't my main work language anymore so working on this has proved to be quite a context switch. I'm going to try to finish this up now.

The attached patch implements a new pattern for wrapping runpy - one that I hope is a bit more general than just setting argv. In particular, using the new load_module/load_path doesn't automatically change argv at all when calling run. The callers can do pretty much whatever they want before calling run().

From a docs perspective this is quite a bit easies to understand. You call runpy.load_* to find the module, change whatever you want: globals/module dict values/names/etc, and call .run(). We would even expose a convenient `with runpy.ModifiedArgv(argv):` to help with the argv swapping. "Simple" use-cases can continue to use runpy.run_* without needing to get into the save/restore we do here.

Let me know what you think of this approach and I can flesh out the docs around it. Otherwise, I'm more than happy to implement the callback approach you suggested.

Date User Action Args
2016-10-23 22:42:54mikekapsetrecipients: + mikekap, ncoghlan, eric.snow
2016-10-23 22:42:53mikekapsetmessageid: <>
2016-10-23 22:42:53mikekaplinkissue26388 messages
2016-10-23 22:42:53mikekapcreate