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

login
register
mail settings
Submitter Boris Feld
Date Nov. 19, 2017, 8:27 p.m.
Message ID <f8c7e82981aeae23514f.1511123268@FB>
Download mbox | patch
Permalink /patch/25646/
State Accepted
Headers show

Comments

Boris Feld - Nov. 19, 2017, 8:27 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@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.
Augie Fackler - Nov. 20, 2017, 10 p.m.
On Sun, Nov 19, 2017 at 09:27:48PM +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@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

queued, thanks

Patch

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):