Skip to content

Commit

Permalink
Avoid importing a non-vendored version of Tornado
Browse files Browse the repository at this point in the history
Code depending on this conditional import could break if an old
version of Tornado is present in the environment, rendering pip
unusable.

Fixes pypa#10020
  • Loading branch information
Ben Darnell authored and bdarnell committed May 29, 2021
1 parent 74580b1 commit 3b655ef
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions news/10020.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove unused optional ``tornado`` import in vendored ``tenacity`` to prevent old versions of Tornado from breaking pip.
7 changes: 3 additions & 4 deletions src/pip/_vendor/tenacity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@
except ImportError:
iscoroutinefunction = None

try:
import tornado
except ImportError:
tornado = None
# Pip does not currently vendor Tornado, so don't import it even if it
# happens to be installed in the environment.
tornado = None

import sys
import threading
Expand Down
18 changes: 18 additions & 0 deletions tools/vendoring/patches/tenacity.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/src/pip/_vendor/tenacity/__init__.py b/src/pip/_vendor/tenacity/__init__.py
index 5f8cb5058..c2b4d9acc 100644
--- a/src/pip/_vendor/tenacity/__init__.py
+++ b/src/pip/_vendor/tenacity/__init__.py
@@ -22,10 +22,9 @@ try:
except ImportError:
iscoroutinefunction = None

-try:
- import tornado
-except ImportError:
- tornado = None
+# Pip does not currently vendor Tornado, so don't import it even if it
+# happens to be installed in the environment.
+tornado = None

import sys
import threading

0 comments on commit 3b655ef

Please sign in to comment.