Skip to content

Commit

Permalink
Remove _eval_code_with_locals (no longer needed since pyodide#1167 wa…
Browse files Browse the repository at this point in the history
…s merged)
  • Loading branch information
Hood committed Feb 4, 2021
1 parent 43711a5 commit a0517ae
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 26 deletions.
4 changes: 0 additions & 4 deletions src/pyodide-py/pyodide/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
eval_code,
find_imports,
as_nested_list,
_eval_code_with_locals,
)
from ._core import JsException # type: ignore
from ._importhooks import JsFinder
Expand All @@ -14,9 +13,6 @@
unregister_js_module = jsfinder.unregister_js_module
sys.meta_path.append(jsfinder) # type: ignore

# Not public, mypy has to be convinced it is used.
_eval_code_with_locals = _eval_code_with_locals

__version__ = "0.16.1"

__all__ = [
Expand Down
20 changes: 0 additions & 20 deletions src/pyodide-py/pyodide/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,26 +250,6 @@ async def run_async(self, code: str) -> Any:
res = await res
return res


def _eval_code_with_locals(
code: str,
globals: Optional[Dict[str, Any]] = None,
return_mode: str = "last_expr",
quiet_trailing_semicolon: bool = True,
filename: str = "<exec>",
) -> Any:
""" Runs a code string in a new empty locals dict. Other arguments as as for eval_code. """
# TODO: remove this once we fix type conversions code (should be possible to create a dict in js!)
return eval_code(
code,
globals=globals,
locals={}, # New empty locals dict
return_mode=return_mode,
quiet_trailing_semicolon=quiet_trailing_semicolon,
filename=filename,
)


def eval_code(
code: str,
globals: Optional[Dict[str, Any]] = None,
Expand Down
8 changes: 6 additions & 2 deletions src/pyodide.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,12 @@ globalThis.languagePluginLoader = new Promise((resolve, reject) => {
};

Module.runPython = code => Module.pyodide_py.eval_code(code, Module.globals);
Module.runPythonWithLocals = code =>
Module.pyodide_py._eval_code_with_locals(code, Module.globals);
Module.runPythonWithLocals = code => {
let locals = Module.globals.dict();
let result = Module.pyodide_py.eval_code(code, Module.globals, locals);
locals.destroy();
return result;
}

// clang-format off
Module.loadPackagesFromImports = async function(code, messageCallback, errorCallback) {
Expand Down

0 comments on commit a0517ae

Please sign in to comment.