Skip to content

Commit 0d3f03c

Browse files
committed
Upgrade colorama to 0.4.5
1 parent 909be0d commit 0d3f03c

File tree

8 files changed

+50
-26
lines changed

8 files changed

+50
-26
lines changed

news/colorama.vendor.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Upgrade colorama to 0.4.5

src/pip/_vendor/colorama/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
from .ansi import Fore, Back, Style, Cursor
44
from .ansitowin32 import AnsiToWin32
55

6-
__version__ = '0.4.4'
6+
__version__ = '0.4.5'

src/pip/_vendor/colorama/ansitowin32.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ def __enter__(self, *args, **kwargs):
3737
def __exit__(self, *args, **kwargs):
3838
return self.__wrapped.__exit__(*args, **kwargs)
3939

40+
def __setstate__(self, state):
41+
self.__dict__ = state
42+
43+
def __getstate__(self):
44+
return self.__dict__
45+
4046
def write(self, text):
4147
self.__convertor.write(text)
4248

@@ -57,7 +63,9 @@ def closed(self):
5763
stream = self.__wrapped
5864
try:
5965
return stream.closed
60-
except AttributeError:
66+
# AttributeError in the case that the stream doesn't support being closed
67+
# ValueError for the case that the stream has already been detached when atexit runs
68+
except (AttributeError, ValueError):
6169
return True
6270

6371

src/pip/_vendor/requests/__init__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@
4444
import warnings
4545
from .exceptions import RequestsDependencyWarning
4646

47-
charset_normalizer_version = None
47+
try:
48+
from charset_normalizer import __version__ as charset_normalizer_version
49+
except ImportError:
50+
charset_normalizer_version = None
4851

4952
try:
5053
from pip._vendor.chardet import __version__ as chardet_version
@@ -104,11 +107,6 @@ def _check_cryptography(cryptography_version):
104107
# if the standard library doesn't support SNI or the
105108
# 'ssl' library isn't available.
106109
try:
107-
# Note: This logic prevents upgrading cryptography on Windows, if imported
108-
# as part of pip.
109-
from pip._internal.utils.compat import WINDOWS
110-
if not WINDOWS:
111-
raise ImportError("pip internals: don't import cryptography on Windows")
112110
try:
113111
import ssl
114112
except ImportError:

src/pip/_vendor/requests/compat.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
Python 3.
99
"""
1010

11-
from pip._vendor import chardet
11+
try:
12+
from pip._vendor import chardet
13+
except ImportError:
14+
import charset_normalizer as chardet
1215

1316
import sys
1417

@@ -25,14 +28,12 @@
2528
#: Python 3.x?
2629
is_py3 = (_ver[0] == 3)
2730

28-
# Note: We've patched out simplejson support in pip because it prevents
29-
# upgrading simplejson on Windows.
30-
# try:
31-
# import simplejson as json
32-
# except (ImportError, SyntaxError):
33-
# # simplejson does not support Python 3.2, it throws a SyntaxError
34-
# # because of u'...' Unicode literals.
35-
import json
31+
has_simplejson = False
32+
try:
33+
import simplejson as json
34+
has_simplejson = True
35+
except ImportError:
36+
import json
3637

3738
# ---------
3839
# Specifics
@@ -67,7 +68,10 @@
6768
# Keep OrderedDict for backwards compatibility.
6869
from collections import OrderedDict
6970
from collections.abc import Callable, Mapping, MutableMapping
70-
from json import JSONDecodeError
71+
if has_simplejson:
72+
from simplejson import JSONDecodeError
73+
else:
74+
from json import JSONDecodeError
7175

7276
builtin_str = str
7377
str = str

src/pip/_vendor/requests/help.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111

1212
from . import __version__ as requests_version
1313

14-
charset_normalizer = None
14+
try:
15+
import charset_normalizer
16+
except ImportError:
17+
charset_normalizer = None
1518

1619
try:
1720
from pip._vendor import chardet

src/pip/_vendor/requests/packages.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
import sys
22

3+
try:
4+
from pip._vendor import chardet
5+
except ImportError:
6+
import charset_normalizer as chardet
7+
import warnings
8+
9+
warnings.filterwarnings('ignore', 'Trying to detect', module='charset_normalizer')
10+
311
# This code exists for backwards compatibility reasons.
412
# I don't like it either. Just look the other way. :)
513

6-
for package in ('urllib3', 'idna', 'chardet'):
7-
vendored_package = "pip._vendor." + package
8-
locals()[package] = __import__(vendored_package)
14+
for package in ('urllib3', 'idna'):
15+
locals()[package] = __import__(package)
916
# This traversal is apparently necessary such that the identities are
1017
# preserved (requests.packages.urllib3.* is urllib3.*)
1118
for mod in list(sys.modules):
12-
if mod == vendored_package or mod.startswith(vendored_package + '.'):
13-
unprefixed_mod = mod[len("pip._vendor."):]
14-
sys.modules['pip._vendor.requests.packages.' + unprefixed_mod] = sys.modules[mod]
19+
if mod == package or mod.startswith(package + '.'):
20+
sys.modules['requests.packages.' + mod] = sys.modules[mod]
1521

22+
target = chardet.__name__
23+
for mod in list(sys.modules):
24+
if mod == target or mod.startswith(target + '.'):
25+
sys.modules['requests.packages.' + target.replace(target, 'chardet')] = sys.modules[mod]
1626
# Kinda cool, though, right?

src/pip/_vendor/vendor.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CacheControl==0.12.11 # Make sure to update the license in pyproject.toml for this.
2-
colorama==0.4.4
2+
colorama==0.4.5
33
distlib==0.3.3
44
distro==1.7.0
55
msgpack==1.0.3

0 commit comments

Comments
 (0)