зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1712133: Use if/else chain instead of early-return in handle_package r=ahal
Accidentally missing a `return` in a code path could mean that `handle_package(...)` would accidentally do an action _and_ raise the "Unknown action" error. This change resolves that, and it simplifies the code a bit. Differential Revision: https://phabricator.services.mozilla.com/D115923
This commit is contained in:
Родитель
0d1d6ed813
Коммит
17f68a38c4
|
@ -355,14 +355,11 @@ class VirtualenvManager(VirtualenvHelper):
|
||||||
populate_local_paths=self.populate_local_paths,
|
populate_local_paths=self.populate_local_paths,
|
||||||
)
|
)
|
||||||
submanager.populate(sitecustomize=sitecustomize)
|
submanager.populate(sitecustomize=sitecustomize)
|
||||||
|
elif package[0].endswith(".pth"):
|
||||||
return True
|
|
||||||
|
|
||||||
if package[0].endswith(".pth"):
|
|
||||||
assert len(package) == 2
|
assert len(package) == 2
|
||||||
|
|
||||||
if not self.populate_local_paths:
|
if not self.populate_local_paths:
|
||||||
return True
|
return
|
||||||
|
|
||||||
path = os.path.join(self.topsrcdir, package[1])
|
path = os.path.join(self.topsrcdir, package[1])
|
||||||
|
|
||||||
|
@ -372,28 +369,20 @@ class VirtualenvManager(VirtualenvHelper):
|
||||||
# to be moved around (as long as the paths relative to
|
# to be moved around (as long as the paths relative to
|
||||||
# each other remain the same).
|
# each other remain the same).
|
||||||
f.write("%s\n" % os.path.relpath(path, python_lib))
|
f.write("%s\n" % os.path.relpath(path, python_lib))
|
||||||
return True
|
elif package[0] == "thunderbird":
|
||||||
|
|
||||||
if package[0] == "thunderbird":
|
|
||||||
if is_thunderbird:
|
if is_thunderbird:
|
||||||
return handle_package(package[1:])
|
handle_package(package[1:])
|
||||||
else:
|
elif package[0] in ("windows", "!windows"):
|
||||||
return True
|
|
||||||
|
|
||||||
if package[0] in ("windows", "!windows"):
|
|
||||||
for_win = not package[0].startswith("!")
|
for_win = not package[0].startswith("!")
|
||||||
is_win = sys.platform == "win32"
|
is_win = sys.platform == "win32"
|
||||||
if is_win == for_win:
|
if is_win == for_win:
|
||||||
return handle_package(package[1:])
|
handle_package(package[1:])
|
||||||
return True
|
elif package[0] in ("python2", "python3"):
|
||||||
|
|
||||||
if package[0] in ("python2", "python3"):
|
|
||||||
for_python3 = package[0].endswith("3")
|
for_python3 = package[0].endswith("3")
|
||||||
if PY3 == for_python3:
|
if PY3 == for_python3:
|
||||||
return handle_package(package[1:])
|
handle_package(package[1:])
|
||||||
return True
|
else:
|
||||||
|
raise Exception("Unknown action: %s" % package[0])
|
||||||
raise Exception("Unknown action: %s" % package[0])
|
|
||||||
|
|
||||||
# We always target the OS X deployment target that Python itself was
|
# We always target the OS X deployment target that Python itself was
|
||||||
# built with, regardless of what's in the current environment. If we
|
# built with, regardless of what's in the current environment. If we
|
||||||
|
|
Загрузка…
Ссылка в новой задаче