Skip to content

Commit e7630ac

Browse files
committed
Use the runsource method of interpreter object in bpython.args.exec_code().
__future__ imports affect the compilation of subsequent code. The interpreter object's compile method keeps track of which __future__ imports it has already seen, while the built-in compile function doesn't. Closes #369.
1 parent ffa49f0 commit e7630ac

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

bpython/args.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ def exec_code(interpreter, args):
104104
sys.argv
105105
"""
106106
with open(args[0], 'r') as sourcefile:
107-
code_obj = compile(sourcefile.read(), args[0], 'exec')
107+
source = sourcefile.read()
108108
old_argv, sys.argv = sys.argv, args
109109
sys.path.insert(0, os.path.abspath(os.path.dirname(args[0])))
110-
interpreter.runcode(code_obj)
110+
interpreter.runsource(source, args[0], 'exec')
111111
sys.argv = old_argv

bpython/test/test_curtsies_repl.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ def test_repl(self):
9999
repl.push('1 / 2')
100100
self.assertEqual(out.getvalue(), '0.5\n')
101101

102-
@skip('Failing - this is issue #369')
103102
def test_interactive(self):
104103
interp = code.InteractiveInterpreter(locals={})
105104
with captured_output() as (out, err):

0 commit comments

Comments
 (0)