Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyodide
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
pyodide
Commits
9f7f4826
Commit
9f7f4826
authored
Jan 23, 2019
by
Michael Droettboom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix iodide-project/iodide#1423: Don't crash if there is no Python code
parent
82928533
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
0 deletions
+8
-0
src/pyodide.py
src/pyodide.py
+3
-0
test/test_python.py
test/test_python.py
+5
-0
No files found.
src/pyodide.py
View file @
9f7f4826
...
@@ -29,6 +29,9 @@ def eval_code(code, ns):
...
@@ -29,6 +29,9 @@ def eval_code(code, ns):
code
=
dedent
(
code
)
code
=
dedent
(
code
)
mod
=
ast
.
parse
(
code
)
mod
=
ast
.
parse
(
code
)
if
len
(
mod
.
body
)
==
0
:
return
None
if
isinstance
(
mod
.
body
[
-
1
],
ast
.
Expr
):
if
isinstance
(
mod
.
body
[
-
1
],
ast
.
Expr
):
expr
=
ast
.
Expression
(
mod
.
body
[
-
1
].
value
)
expr
=
ast
.
Expression
(
mod
.
body
[
-
1
].
value
)
del
mod
.
body
[
-
1
]
del
mod
.
body
[
-
1
]
...
...
test/test_python.py
View file @
9f7f4826
...
@@ -645,3 +645,8 @@ def test_py(selenium_standalone):
...
@@ -645,3 +645,8 @@ def test_py(selenium_standalone):
)
)
assert
selenium_standalone
.
run_js
(
'return pyodide.globals.func()'
)
==
42
assert
selenium_standalone
.
run_js
(
'return pyodide.globals.func()'
)
==
42
def
test_eval_nothing
(
selenium
):
assert
selenium
.
run
(
'# comment'
)
is
None
assert
selenium
.
run
(
''
)
is
None
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment