mirror of https://github.com/pyodide/pyodide.git
Fix "from js import foo"
This commit is contained in:
parent
0e8963a480
commit
f1e0cc9085
|
@ -32,13 +32,11 @@ PyObject *jsToPython(val x) {
|
|||
PyObject *pypy_x = py_x.x;
|
||||
Py_INCREF(pypy_x);
|
||||
return pypy_x;
|
||||
} else if (!x["byteLength"].isUndefined()) {
|
||||
std::string x_str = x.as<std::string>();
|
||||
return PyBytes_FromStringAndSize(x_str.c_str(), x_str.size());
|
||||
} else {
|
||||
try {
|
||||
std::string x_str = x.as<std::string>();
|
||||
return PyBytes_FromStringAndSize(x_str.c_str(), x_str.size());
|
||||
} catch (...) {
|
||||
return JsProxy_cnew(x);
|
||||
}
|
||||
return JsProxy_cnew(x);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,12 @@ def test_print(selenium):
|
|||
assert 'This should be logged' in selenium.logs
|
||||
|
||||
|
||||
def test_import_js(selenium):
|
||||
result = selenium.run(
|
||||
"from js import window\nwindow.title = 'Foo'\nwindow.title")
|
||||
assert result == 'Foo'
|
||||
|
||||
|
||||
def test_run_core_python_test(python_test, selenium):
|
||||
selenium.run(
|
||||
"import sys\n"
|
||||
|
|
Loading…
Reference in New Issue