Bug 1339409 - mozboot: Fix undefined FileNotFoundError. r?chmanchester
The FileNotFoundError built-in exception is only present in
python 3. Emulate its behaviour in python 2 with a conditional
OSError.
MozReview-Commit-ID: 4b8THPG7jph
--- a/python/mozboot/mozboot/mozillabuild.py
+++ b/python/mozboot/mozboot/mozillabuild.py
@@ -1,12 +1,13 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+import errno
import os
import sys
import subprocess
import tempfile
from mozboot.base import BaseBootstrapper
class MozillaBuildBootstrapper(BaseBootstrapper):
@@ -40,18 +41,21 @@ class MozillaBuildBootstrapper(BaseBoots
f.write(' export PATH\n')
f.write('fi')
_, cargo_bin = self.cargo_home()
rustup = os.path.join(cargo_bin, 'rustup')
self.run([rustup, 'target', 'add', 'i686-pc-windows-msvc'])
finally:
try:
os.remove(rustup_init)
- except FileNotFoundError:
- pass
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ pass
+ else:
+ raise
def upgrade_mercurial(self, current):
self.pip_install('mercurial')
def upgrade_python(self, current):
pass
def install_browser_packages(self):