Bug 899695 - Fix exception in "mach python" on Windows [r=gps]
authorMatt Brubeck <mbrubeck@mozilla.com>
Thu, 08 Aug 2013 08:06:02 -0700
changeset 155640 3fc5338cc5b1fb9b42e2f35bc25e66c516285668
parent 155639 0b5f99a3db3596d11d1708fa2add47ecbdc9da08
child 155641 e966eb34cc03a7b3e8f6ba30a235a1cd2346873d
push id407
push userlsblakk@mozilla.com
push dateTue, 03 Dec 2013 03:32:50 +0000
treeherdermozilla-release@babf8c9ebc52 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs899695
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 899695 - Fix exception in "mach python" on Windows [r=gps] DONTBUILD (not part of the build)
mach
python/mach_commands.py
testing/mochitest/mach_commands.py
--- a/mach
+++ b/mach
@@ -28,18 +28,17 @@ for dir_path in ancestors(os.getcwd()):
         import json
         info = json.load(open(mozinfo_path))
         if "mozconfig" in info and "MOZCONFIG" not in os.environ:
             # If the MOZCONFIG environment variable is not already set, set it
             # to the value from mozinfo.json.  This will tell the build system
             # to look for a config file at the path in $MOZCONFIG rather than
             # its default locations.
             #
-            # Note: subprocess requires native strings in os.environ Python
-            # 2.7.2 and earlier on Windows.
+            # Note: subprocess requires native strings in os.environ on Windows
             os.environ[b"MOZCONFIG"] = str(info["mozconfig"])
 
         if "topsrcdir" in info:
             # Continue searching for mach_bootstrap in the source directory.
             dir_path = info["topsrcdir"]
 
     # If we find the mach bootstrap module, we are in the srcdir.
     mach_path = os.path.join(dir_path, "build/mach_bootstrap.py")
--- a/python/mach_commands.py
+++ b/python/mach_commands.py
@@ -54,17 +54,18 @@ class MachCommands(MachCommandBase):
     @Command('python', category='devenv',
         allow_all_args=True,
         description='Run Python.')
     @CommandArgument('args', nargs=argparse.REMAINDER)
     def python(self, args):
         return self.run_process([self.python_executable] + args,
             pass_thru=True, # Allow user to run Python interactively.
             ensure_exit_code=False, # Don't throw on non-zero exit code.
-            append_env={'PYTHONDONTWRITEBYTECODE': '1'})
+            # Note: subprocess requires native strings in os.environ on Windows
+            append_env={b'PYTHONDONTWRITEBYTECODE': str('1')})
 
     @Command('python-test', category='testing',
         description='Run Python unit tests.')
     @CommandArgument('--verbose',
         default=False,
         action='store_true',
         help='Verbose output.')
     @CommandArgument('--stop',
@@ -104,17 +105,18 @@ class MachCommands(MachCommandBase):
             def _line_handler(line):
                 if not file_displayed_test and line.startswith('TEST-'):
                     file_displayed_test.append(True)
 
             inner_return_code = self.run_process(
                 [self.python_executable, file],
                 ensure_exit_code=False, # Don't throw on non-zero exit code.
                 log_name='python-test',
-                append_env={'PYTHONDONTWRITEBYTECODE': '1'},
+                # subprocess requires native strings in os.environ on Windows
+                append_env={b'PYTHONDONTWRITEBYTECODE': str('1')},
                 line_handler=_line_handler)
             return_code += inner_return_code
 
             if not file_displayed_test:
                 self.log(logging.WARN, 'python-test', {'file': file},
                          'TEST-UNEXPECTED-FAIL | No test output (missing mozunit.main() call?): {file}')
 
             if verbose:
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -144,17 +144,16 @@ class MochitestRunner(MozbuildObject):
             test_root = runner.getTestRoot(options)
             test_root_file = mozpack.path.join(mochitest_dir, test_root, test_path)
             if not os.path.exists(test_root_file):
                 print('Specified test path does not exist: %s' % test_root_file)
                 print('You may need to run |mach build| to build the test files.')
                 return 1
 
             options.testPath = test_path
-            env = {'TEST_PATH': test_path}
 
         if rerun_failures:
             options.testManifest = failure_file_path
 
         if debugger:
             options.debugger = debugger
 
         if debugger_args: