From 72b6b9904d97be20a6f14eb300dbd011a5fa336a Mon Sep 17 00:00:00 2001
From: Brennan Ashton <bashton@brennanashton.com>
Date: Sat, 3 Nov 2018 15:04:32 -0700
Subject: 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.
---
 grc/core/FlowGraph.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

(limited to 'grc/core/FlowGraph.py')

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:
-- 
cgit v1.2.3