Skip to content

Commit

Permalink
Merge pull request #9460 from pfmoore/vendor_21_0
Browse files Browse the repository at this point in the history
Vendoring changes for release 21.0 (excluding setuptools)
  • Loading branch information
pfmoore authored Jan 16, 2021
2 parents aa08988 + a79758c commit 7b7469b
Show file tree
Hide file tree
Showing 30 changed files with 33,052 additions and 1,962 deletions.
1 change: 1 addition & 0 deletions news/msgpack.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade msgpack to 1.0.2.
1 change: 1 addition & 0 deletions news/requests.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade requests to 2.25.1.
2 changes: 1 addition & 1 deletion src/pip/_vendor/certifi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .core import contents, where

__version__ = "2020.11.08"
__version__ = "2020.12.05"
363 changes: 41 additions & 322 deletions src/pip/_vendor/certifi/cacert.pem

Large diffs are not rendered by default.

48 changes: 46 additions & 2 deletions src/pip/_vendor/chardet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
######################### END LICENSE BLOCK #########################


from .compat import PY2, PY3
from .universaldetector import UniversalDetector
from .enums import InputState
from .version import __version__, VERSION


__all__ = ['UniversalDetector', 'detect', 'detect_all', '__version__', 'VERSION']


def detect(byte_str):
"""
Detect the encoding of the given byte string.
Expand All @@ -31,9 +34,50 @@ def detect(byte_str):
if not isinstance(byte_str, bytearray):
if not isinstance(byte_str, bytes):
raise TypeError('Expected object of type bytes or bytearray, got: '
'{0}'.format(type(byte_str)))
'{}'.format(type(byte_str)))
else:
byte_str = bytearray(byte_str)
detector = UniversalDetector()
detector.feed(byte_str)
return detector.close()


def detect_all(byte_str):
"""
Detect all the possible encodings of the given byte string.
:param byte_str: The byte sequence to examine.
:type byte_str: ``bytes`` or ``bytearray``
"""
if not isinstance(byte_str, bytearray):
if not isinstance(byte_str, bytes):
raise TypeError('Expected object of type bytes or bytearray, got: '
'{}'.format(type(byte_str)))
else:
byte_str = bytearray(byte_str)

detector = UniversalDetector()
detector.feed(byte_str)
detector.close()

if detector._input_state == InputState.HIGH_BYTE:
results = []
for prober in detector._charset_probers:
if prober.get_confidence() > detector.MINIMUM_THRESHOLD:
charset_name = prober.charset_name
lower_charset_name = prober.charset_name.lower()
# Use Windows encoding name instead of ISO-8859 if we saw any
# extra Windows-specific bytes
if lower_charset_name.startswith('iso-8859'):
if detector._has_win_bytes:
charset_name = detector.ISO_WIN_MAP.get(lower_charset_name,
charset_name)
results.append({
'encoding': charset_name,
'confidence': prober.get_confidence(),
'language': prober.language,
})
if len(results) > 0:
return sorted(results, key=lambda result: -result['confidence'])

return [detector.result]
1 change: 1 addition & 0 deletions src/pip/_vendor/chardet/charsetgroupprober.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def feed(self, byte_str):
continue
if state == ProbingState.FOUND_IT:
self._best_guess_prober = prober
self._state = ProbingState.FOUND_IT
return self.state
elif state == ProbingState.NOT_ME:
prober.active = False
Expand Down
7 changes: 3 additions & 4 deletions src/pip/_vendor/chardet/cli/chardetect.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python
"""
Script which takes one or more file paths and reports on their detected
encodings
Expand Down Expand Up @@ -45,10 +44,10 @@ def description_of(lines, name='stdin'):
if PY2:
name = name.decode(sys.getfilesystemencoding(), 'ignore')
if result['encoding']:
return '{0}: {1} with confidence {2}'.format(name, result['encoding'],
return '{}: {} with confidence {}'.format(name, result['encoding'],
result['confidence'])
else:
return '{0}: no result'.format(name)
return '{}: no result'.format(name)


def main(argv=None):
Expand All @@ -69,7 +68,7 @@ def main(argv=None):
type=argparse.FileType('rb'), nargs='*',
default=[sys.stdin if PY2 else sys.stdin.buffer])
parser.add_argument('--version', action='version',
version='%(prog)s {0}'.format(__version__))
version='%(prog)s {}'.format(__version__))
args = parser.parse_args(argv)

for f in args.input:
Expand Down
6 changes: 4 additions & 2 deletions src/pip/_vendor/chardet/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
if sys.version_info < (3, 0):
PY2 = True
PY3 = False
base_str = (str, unicode)
string_types = (str, unicode)
text_type = unicode
iteritems = dict.iteritems
else:
PY2 = False
PY3 = True
base_str = (bytes, str)
string_types = (bytes, str)
text_type = str
iteritems = dict.items
Loading

0 comments on commit 7b7469b

Please sign in to comment.