From 070a000dd49aac4a26147e137efcd91a728d13b8 Mon Sep 17 00:00:00 2001 From: Makoto Kato Date: Fri, 6 Mar 2020 17:30:27 +0000 Subject: [PATCH] Bug 1620511 - Make ensure_mobile_android_packages Python3 compatible. r=firefox-build-system-reviewers,rstewart Differential Revision: https://phabricator.services.mozilla.com/D65683 --HG-- extra : moz-landing-system : lando --- python/mozboot/mozboot/mozillabuild.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/python/mozboot/mozboot/mozillabuild.py b/python/mozboot/mozboot/mozillabuild.py index 601f2f8f2763..114e8d751dbc 100644 --- a/python/mozboot/mozboot/mozillabuild.py +++ b/python/mozboot/mozboot/mozillabuild.py @@ -74,15 +74,18 @@ class MozillaBuildBootstrapper(BaseBootstrapper): def ensure_mobile_android_packages(self, artifact_mode=False): # Get java path from registry key - import _winreg + try: + import _winreg + except ImportError: + import winreg as _winreg key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\JavaSoft\Java Development Kit\1.8') java_path, regtype = _winreg.QueryValueEx(key, 'JavaHome') _winreg.CloseKey(key) - os.environ['PATH'] = \ - '{}{}{}'.format(os.path.join(java_path, 'bin'), os.pathsep, - os.environ['PATH']).encode('mbcs') + from mach.util import setenv + setenv('PATH', '{}{}{}'.format(os.path.join(java_path, 'bin'), os.pathsep, + os.environ['PATH'])) self.ensure_java() from mozboot import android