Skip to content

Likely fix for issue #10 #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions pyonic/interpreter_subprocess/interpreter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import copy
from time import sleep

__input = None
Expand Down Expand Up @@ -40,8 +39,7 @@ def _exec_full(filepath):
raw_input = input_replacement
input = eval_input_replacement

user_locals = copy.copy(locals())
user_globals = copy.copy(globals())
user_globals = globals().copy()

import time
import ast
Expand Down Expand Up @@ -221,14 +219,14 @@ def interpret_code(code):
if len(components) > 1:
for component in components[:-1]:
c = compile(ast.Module([component]), '<stdin>', mode='exec')
exec(c, user_locals, user_globals)
exec(c, user_globals)

# if the last ast component is an Expr, compile in single mode to print it
if isinstance(components[-1], ast.Expr):
c = compile(ast.Interactive([components[-1]]), '<stdin>', mode='single')
else:
c = compile(ast.Module([components[-1]]), '<stdin>', mode='exec')
exec(c, user_locals, user_globals)
exec(c, user_globals)

except KeyboardInterrupt as e:
print('')
Expand Down