[python] fill user namespace for programs without PY_MAIN in :repl entry point
This enables loading __main__.py contents for python binaries run with Y_PYTHON_ENTRY_POINT=":repl".
With this patch `ya py` will nicely start shell for python programs.
@@ -23,7 +23,7 @@ def repl():
import traceback
traceback.print_exc()
- if py_main and '__main__' not in user_ns:
+ if '__main__' not in user_ns:
def run(args):
if isinstance(args, basestring):
import shlex
@@ -34,6 +34,12 @@ def repl():
getattr(mod, func_name)()
user_ns['__main__'] = run
+ else:
+ try:
+ mod = __res.importer.load_module('__main__', fix_name='__main_real')
+ user_ns = mod.__dict__
+ except ImportError:
+ pass
try:
import IPython
