Message279288
| Author |
mikekap |
| Recipients |
eric.snow, mikekap, ncoghlan |
| Date |
2016年10月23日.22:42:51 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1477262573.83.0.622019005628.issue26388@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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.
Thanks,
Mike. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2016年10月23日 22:42:54 | mikekap | set | recipients:
+ mikekap, ncoghlan, eric.snow |
| 2016年10月23日 22:42:53 | mikekap | set | messageid: <1477262573.83.0.622019005628.issue26388@psf.upfronthosting.co.za> |
| 2016年10月23日 22:42:53 | mikekap | link | issue26388 messages |
| 2016年10月23日 22:42:53 | mikekap | create |
|