From a33048d500bdad5dd7232ac6f4d117fc9df8dd32 Mon Sep 17 00:00:00 2001 From: thekthuser Date: Sun, 26 Apr 2015 16:56:07 -0400 Subject: [PATCH] fixed bug #506 --- bpython/args.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bpython/args.py b/bpython/args.py index 6fd2b519c..91c8fc7fe 100644 --- a/bpython/args.py +++ b/bpython/args.py @@ -3,9 +3,10 @@ """ from __future__ import print_function +import code +import imp import os import sys -import code from optparse import OptionParser, OptionGroup from bpython import __version__ @@ -114,6 +115,9 @@ def exec_code(interpreter, args): source = sourcefile.read() old_argv, sys.argv = sys.argv, args sys.path.insert(0, os.path.abspath(os.path.dirname(args[0]))) + mod = imp.new_module('__console__') + sys.modules['__console__'] = mod + interpreter.locals = mod.__dict__ interpreter.locals['__file__'] = args[0] interpreter.runsource(source, args[0], 'exec') sys.argv = old_argv