Internal change

PiperOrigin-RevId: 350587882
Change-Id: I39000bc11bcc17e8ca0e5e55a90df72b66b676cf
diff --git a/tools/automate-git.py b/tools/automate-git.py
index 284e950..38344dc 100644
--- a/tools/automate-git.py
+++ b/tools/automate-git.py
@@ -347,6 +347,7 @@
     fp.write(u"""
 # Google-specific code starts here.
 import os
+import sys
 
 # Location of Google-specific patches.
 google_patch_path = %s
@@ -366,7 +367,9 @@
 # Execute the Google-specific patch config file in the current scope. The config
 # file will call register_google_patches one or more times to register patches.
 if os.path.isfile(google_patch_config_file):
-  execfile(google_patch_config_file)
+  exec(compile(open(google_patch_config_file, 'rb').read(),
+               google_patch_config_file, 'exec'),
+       sys._getframe(1).f_globals)
 # Google-specific code ends here.
 """ % repr(google_patch_path))