Skip to content

Commit

Permalink
Merge pull request #10029 from bdarnell/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr committed May 31, 2021
2 parents 8fe0011 + b8f1fcf commit 5554432
Show file tree
Hide file tree
Showing 3 changed files with 28 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.
10 changes: 6 additions & 4 deletions src/pip/_vendor/tenacity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions tools/vendoring/patches/tenacity.patch
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5554432

Please sign in to comment.