parameters: (code, init_globals=None,
                      mod_name=None, mod_spec=None,
                      pkg_name=None, script_name=None)
return_statement: return mod_globals.copy()
docstring: Helper to run code in new namespace with sys modified
docstring_summary: Helper to run code in new namespace with sys modified
docstring_tokens: Helper to run code in new namespace with sys modified
function: def _run_module_code(code, init_globals=None,
                      mod_name=None, mod_spec=None,
                      pkg_name=None, script_name=None):
      """Helper to run code in new namespace with sys modified"""
      fname = script_name if mod_spec is None else mod_spec.origin
      with _TempModule(mod_name) as temp_module, _ModifiedArgv0(fname):
          mod_globals = temp_module.module.__dict__
          _run_code(code, mod_globals, init_globals,
                    mod_name, mod_spec, pkg_name, script_name)
      # Copy the globals of the temporary module, as they
      # may be cleared when the temporary module goes away
      return mod_globals.copy()
function_tokens: def _run_module_code ( code , init_globals = None , mod_name = None , mod_spec = None , pkg_name = None , script_name = None ) : fname = script_name if mod_spec is None else mod_spec . origin with _TempModule ( mod_name ) as temp_module , _ModifiedArgv0 ( fname ) : mod_globals = temp_module . module . __dict__ _run_code ( code , mod_globals , init_globals , mod_name , mod_spec , pkg_name , script_name ) # Copy the globals of the temporary module, as they # may be cleared when the temporary module goes away return mod_globals . copy ( )