Skip to content

Commit a81b83f

Browse files
author
Noah Gorny
committed
cmdoptions: Check if format_control exists before accessing it
Fixes a case when per-setup.py options are specified in a requirement file, and we are trying to invoke uninstall
1 parent d9d7790 commit a81b83f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

news/9444.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Permit ``pip uninstall -r`` to accept requirements files containing ``--install-option`` or ``--global-option``.

src/pip/_internal/cli/cmdoptions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ def getname(n):
7575
return getattr(check_options, n, None)
7676

7777
names = ["build_options", "global_options", "install_options"]
78-
if any(map(getname, names)):
79-
control = options.format_control
78+
79+
control = getattr(options, "format_control", None)
80+
if control and any(map(getname, names)):
8081
control.disallow_binaries()
8182
warnings.warn(
8283
"Disabling all use of wheels due to the use of --build-option "

0 commit comments

Comments
 (0)