Skip to content

Commit a33048d

Browse files
committed
fixed bug #506
1 parent bb1389a commit a33048d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

bpython/args.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
"""
44

55
from __future__ import print_function
6+
import code
7+
import imp
68
import os
79
import sys
8-
import code
910
from optparse import OptionParser, OptionGroup
1011

1112
from bpython import __version__
@@ -114,6 +115,9 @@ def exec_code(interpreter, args):
114115
source = sourcefile.read()
115116
old_argv, sys.argv = sys.argv, args
116117
sys.path.insert(0, os.path.abspath(os.path.dirname(args[0])))
118+
mod = imp.new_module('__console__')
119+
sys.modules['__console__'] = mod
120+
interpreter.locals = mod.__dict__
117121
interpreter.locals['__file__'] = args[0]
118122
interpreter.runsource(source, args[0], 'exec')
119123
sys.argv = old_argv

0 commit comments

Comments
 (0)