[PATCH 2 of 2] run-test: drop 'execfile' usage for 'common-pattern.py' file

Boris Feld boris.feld at octobus.net
Sun Nov 19 15:27:48 EST 2017


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1511061081 -3600
#      Sun Nov 19 04:11:21 2017 +0100
# Node ID f8c7e82981aeae23514f38a4f185bf4ac9c65208
# Parent  bce28660d7df4043e7ee295d1fa6be90cacbe128
# EXP-Topic run-test-fixes
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r f8c7e82981ae
run-test: drop 'execfile' usage for 'common-pattern.py' file

This is required for Python 3.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -973,8 +973,11 @@ class Test(unittest.TestCase):
 
         if os.path.exists(replacementfile):
             data = {}
-            execfile(replacementfile, data)
-            r.extend(data.get('substitutions', ()))
+            with open(replacementfile, mode='rb') as source:
+                # the intermediate 'compile' step help with debugging
+                code = compile(source.read(), replacementfile, 'exec')
+                exec(code, data)
+                r.extend(data.get('substitutions', ()))
         return r
 
     def _escapepath(self, p):


More information about the Mercurial-devel mailing list