Mike Kaplinskiy added the comment: 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. ---------- Added file: http://bugs.python.org/file45201/patch-2.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26388> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com