summaryrefslogtreecommitdiff
path: root/grc/core/FlowGraph.py
diff options
context:
space:
mode:
authorBrennan Ashton <bashton@brennanashton.com>2018-11-03 15:04:32 -0700
committerMarcus Müller <marcus@hostalia.de>2018-11-04 15:11:11 +0100
commit72b6b9904d97be20a6f14eb300dbd011a5fa336a (patch)
tree944c1ebe38d67e6a96af830599980ae0a932b420 /grc/core/FlowGraph.py
parentabd594ae7df1dd15f9893e190846d789f752ab2d (diff)
grc: Remove deprecated use of imp module
imp module is deprecated as of Python 3.4 but in Python3 we can use the ModuleType to create a new module.
Diffstat (limited to 'grc/core/FlowGraph.py')
-rw-r--r--grc/core/FlowGraph.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/grc/core/FlowGraph.py b/grc/core/FlowGraph.py
index 39f998d2aa..138ae44ee5 100644
--- a/grc/core/FlowGraph.py
+++ b/grc/core/FlowGraph.py
@@ -18,7 +18,6 @@
from __future__ import absolute_import, print_function
import collections
-import imp
import itertools
import sys
from operator import methodcaller, attrgetter
@@ -30,6 +29,16 @@ from .utils import expr_utils
from .utils.backports import shlex
+if sys.version_info[0] < 3:
+ import imp
+ def _new_module_helper(name):
+ return imp.new_module(name)
+else:
+ import types
+ def _new_module_helper(name):
+ return types.ModuleType(name)
+
+
class FlowGraph(Element):
is_flow_graph = True
@@ -192,7 +201,7 @@ class FlowGraph(Element):
for id, expr in self.get_python_modules():
try:
- module = imp.new_module(id)
+ module = _new_module_helper(id)
exec(expr, module.__dict__)
namespace[id] = module
except: