Skip to content

Commit 363e90b

Browse files
Ben Darnellsbidoul
Ben Darnell
authored andcommitted
Avoid importing a non-vendored version of Tornado
Code depending on this conditional import could break if an old version of Tornado is present in the environment, rendering pip unusable.
1 parent 4cab55f commit 363e90b

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

news/10020.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove unused optional ``tornado`` import in vendored ``tenacity`` to prevent old versions of Tornado from breaking pip.

src/pip/_vendor/tenacity/__init__.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
except ImportError:
2323
iscoroutinefunction = None
2424

25-
try:
26-
import tornado
27-
except ImportError:
28-
tornado = None
25+
# Replace a conditional import with a hard-coded None so that pip does
26+
# not attempt to use tornado even if it is present in the environment.
27+
# If tornado is non-None, tenacity will attempt to execute some code
28+
# that is sensitive to the version of tornado, which could break pip
29+
# if an old version is found.
30+
tornado = None
2931

3032
import sys
3133
import threading
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
diff --git a/src/pip/_vendor/tenacity/__init__.py b/src/pip/_vendor/tenacity/__init__.py
2+
index 5f8cb5058..42e9d8940 100644
3+
--- a/src/pip/_vendor/tenacity/__init__.py
4+
+++ b/src/pip/_vendor/tenacity/__init__.py
5+
@@ -22,10 +22,12 @@ try:
6+
except ImportError:
7+
iscoroutinefunction = None
8+
9+
-try:
10+
- import tornado
11+
-except ImportError:
12+
- tornado = None
13+
+# Replace a conditional import with a hard-coded None so that pip does
14+
+# not attempt to use tornado even if it is present in the environment.
15+
+# If tornado is non-None, tenacity will attempt to execute some code
16+
+# that is sensitive to the version of tornado, which could break pip
17+
+# if an old version is found.
18+
+tornado = None
19+
20+
import sys
21+
import threading

0 commit comments

Comments
 (0)