From 0b6ddb1acb6176eeb2999dfe518e347f98d97c35 Mon Sep 17 00:00:00 2001
From: Marko Petric <marko.petric@cern.ch>
Date: Thu, 25 Jul 2019 14:12:40 +0200
Subject: [PATCH] replace execfile with call to open compile and exec

---
 DDCore/python/lcdd.py                 | 4 ++--
 DDG4/python/DDSim/DD4hepSimulation.py | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/DDCore/python/lcdd.py b/DDCore/python/lcdd.py
index c6da5a236..771bb5f3c 100644
--- a/DDCore/python/lcdd.py
+++ b/DDCore/python/lcdd.py
@@ -143,12 +143,12 @@ def load_drivers(*args):
     if path.exists(arg):
       if path.isfile(arg):
         logger.info("Loading driver file ... %s" % arg)
-        execfile(arg, drivers)
+        exec(compile(open(arg).read(), arg, 'exec'), drivers)
       elif path.isdir(arg):
         for f in listdir(arg):
           if path.splitext(f)[1] == '.py':
             logger.info("Loading driver file ... %s" % path.join(arg, f))
-            execfile(path.join(arg, f), drivers)
+            exec(compile(open(path.join(arg, f)).read(), path.join(arg, f), 'exec'), drivers)
       else:
         raise "Path '%s' is not a directory or file" % arg
     else:
diff --git a/DDG4/python/DDSim/DD4hepSimulation.py b/DDG4/python/DDSim/DD4hepSimulation.py
index 378d3ba87..d3141dcf0 100644
--- a/DDG4/python/DDSim/DD4hepSimulation.py
+++ b/DDG4/python/DDSim/DD4hepSimulation.py
@@ -116,7 +116,7 @@ class DD4hepSimulation(object):
     if not self.steeringFile:
       return
     sFileTemp = self.steeringFile
-    execfile(self.steeringFile, globs, locs)
+    exec(compile(open(self.steeringFile).read(), self.steeringFile, 'exec'), globs, locs)
     for _name, obj in locs.items():
       if isinstance(obj, DD4hepSimulation):
         self.__dict__ = obj.__dict__
-- 
GitLab