This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
10029.patch
71 lines (67 loc) · 2.57 KB
/
10029.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
From b8f1fcf863081fde0b9d558759c0e3c46ce09a12 Mon Sep 17 00:00:00 2001
From: Ben Darnell <>
Date: Fri, 28 May 2021 16:01:41 +0000
Subject: [PATCH] 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.
---
news/10020.bugfix.rst | 1 +
src/pip/_vendor/tenacity/__init__.py | 10 ++++++----
tools/vendoring/patches/tenacity.patch | 21 +++++++++++++++++++++
3 files changed, 28 insertions(+), 4 deletions(-)
create mode 100644 news/10020.bugfix.rst
create mode 100644 tools/vendoring/patches/tenacity.patch
diff --git a/news/10020.bugfix.rst b/news/10020.bugfix.rst
new file mode 100644
index 00000000000..9425626fb07
--- /dev/null
+++ b/news/10020.bugfix.rst
@@ -0,0 +1 @@
+Remove unused optional ``tornado`` import in vendored ``tenacity`` to prevent old versions of Tornado from breaking pip.
diff --git a/src/pip/_vendor/tenacity/__init__.py b/src/pip/_vendor/tenacity/__init__.py
index 5f8cb505896..42e9d8940b1 100644
--- a/src/pip/_vendor/tenacity/__init__.py
+++ b/src/pip/_vendor/tenacity/__init__.py
@@ -22,10 +22,12 @@
except ImportError:
iscoroutinefunction = None
-try:
- import tornado
-except ImportError:
- tornado = None
+# Replace a conditional import with a hard-coded None so that pip does
+# not attempt to use tornado even if it is present in the environment.
+# If tornado is non-None, tenacity will attempt to execute some code
+# that is sensitive to the version of tornado, which could break pip
+# if an old version is found.
+tornado = None
import sys
import threading
diff --git a/tools/vendoring/patches/tenacity.patch b/tools/vendoring/patches/tenacity.patch
new file mode 100644
index 00000000000..006588b3653
--- /dev/null
+++ b/tools/vendoring/patches/tenacity.patch
@@ -0,0 +1,21 @@
+diff --git a/src/pip/_vendor/tenacity/__init__.py b/src/pip/_vendor/tenacity/__init__.py
+index 5f8cb5058..42e9d8940 100644
+--- a/src/pip/_vendor/tenacity/__init__.py
++++ b/src/pip/_vendor/tenacity/__init__.py
+@@ -22,10 +22,12 @@ try:
+ except ImportError:
+ iscoroutinefunction = None
+
+-try:
+- import tornado
+-except ImportError:
+- tornado = None
++# Replace a conditional import with a hard-coded None so that pip does
++# not attempt to use tornado even if it is present in the environment.
++# If tornado is non-None, tenacity will attempt to execute some code
++# that is sensitive to the version of tornado, which could break pip
++# if an old version is found.
++tornado = None
+
+ import sys
+ import threading