зеркало из 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,
|
||||
)
|
||||
submanager.populate(sitecustomize=sitecustomize)
|
||||
|
||||
return True
|
||||
|
||||
if package[0].endswith(".pth"):
|
||||
elif package[0].endswith(".pth"):
|
||||
assert len(package) == 2
|
||||
|
||||
if not self.populate_local_paths:
|
||||
return True
|
||||
return
|
||||
|
||||
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
|
||||
# each other remain the same).
|
||||
f.write("%s\n" % os.path.relpath(path, python_lib))
|
||||
return True
|
||||
|
||||
if package[0] == "thunderbird":
|
||||
elif package[0] == "thunderbird":
|
||||
if is_thunderbird:
|
||||
return handle_package(package[1:])
|
||||
else:
|
||||
return True
|
||||
|
||||
if package[0] in ("windows", "!windows"):
|
||||
handle_package(package[1:])
|
||||
elif package[0] in ("windows", "!windows"):
|
||||
for_win = not package[0].startswith("!")
|
||||
is_win = sys.platform == "win32"
|
||||
if is_win == for_win:
|
||||
return handle_package(package[1:])
|
||||
return True
|
||||
|
||||
if package[0] in ("python2", "python3"):
|
||||
handle_package(package[1:])
|
||||
elif package[0] in ("python2", "python3"):
|
||||
for_python3 = package[0].endswith("3")
|
||||
if PY3 == for_python3:
|
||||
return handle_package(package[1:])
|
||||
return True
|
||||
|
||||
raise Exception("Unknown action: %s" % package[0])
|
||||
handle_package(package[1:])
|
||||
else:
|
||||
raise Exception("Unknown action: %s" % package[0])
|
||||
|
||||
# We always target the OS X deployment target that Python itself was
|
||||
# built with, regardless of what's in the current environment. If we
|
||||
|
|
Загрузка…
Ссылка в новой задаче