Skip to content

Commit b9f081c

Browse files
committed
Replace imp with importlib (fixes #857)
1 parent 5201a49 commit b9f081c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

bpython/args.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
import code
7-
import imp
7+
import importlib.util
88
import os
99
import sys
1010
from optparse import OptionParser, OptionGroup
@@ -82,7 +82,7 @@ def parse(args, extras=None, ignore_stdin=False):
8282
"-i",
8383
action="store_true",
8484
help=_(
85-
"Drop to bpython shell after running file " "instead of exiting."
85+
"Drop to bpython shell after running file instead of exiting."
8686
),
8787
)
8888
parser.add_option(
@@ -138,7 +138,8 @@ def exec_code(interpreter, args):
138138
source = sourcefile.read()
139139
old_argv, sys.argv = sys.argv, args
140140
sys.path.insert(0, os.path.abspath(os.path.dirname(args[0])))
141-
mod = imp.new_module("__console__")
141+
spec = importlib.util.spec_from_loader("__console__", loader=None)
142+
mod = importlib.util.module_from_spec(spec)
142143
sys.modules["__console__"] = mod
143144
interpreter.locals = mod.__dict__
144145
interpreter.locals["__file__"] = args[0]

0 commit comments

Comments
 (0)