Skip to content

Commit 641e341

Browse files
committed
scripts/mod_python.in: replace use of execfile removed in Python 3 (#139)
Python 3 removed the builtin execfile so this replaces it with read, compile, and exec (see https://stackoverflow.com/questions/436198/). Because this works in both Python 2 and Python 3, we use this alternative unconditionally.
1 parent 9693a38 commit 641e341

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

scripts/mod_python.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ def cmd_genconfig():
6464
if len(args) != 1:
6565
parser.error("Must specify <src>")
6666

67-
execfile(args[0])
67+
src = args[0]
68+
with open(src, "rb") as fh:
69+
exec(compile(fh.read(), src, "exec"))
6870

6971
def cmd_create():
7072

0 commit comments

Comments
 (0)