Skip to content

Commit

Permalink
Import a new version of requests
Browse files Browse the repository at this point in the history
  • Loading branch information
dstufft committed Mar 16, 2018
1 parent b31fbf4 commit 2e142d3
Show file tree
Hide file tree
Showing 124 changed files with 18,915 additions and 7,544 deletions.
10 changes: 3 additions & 7 deletions pip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# to add socks as yet another dependency for pip, nor do I want to allow-stder
# in the DEP-8 tests, so just suppress the warning. pdb tells me this has to
# be done before the import of pip.vcs.
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
from pip._vendor.urllib3.exceptions import DependencyWarning
warnings.filterwarnings("ignore", category=DependencyWarning) # noqa

# We want to inject the use of SecureTransport as early as possible so that any
Expand All @@ -33,9 +33,7 @@
if (sys.platform == "darwin" and
ssl.OPENSSL_VERSION_NUMBER < 0x1000100f): # OpenSSL 1.0.1
try:
from pip._vendor.requests.packages.urllib3.contrib import (
securetransport,
)
from pip._vendor.urllib3.contrib import securetransport
except (ImportError, OSError):
pass
else:
Expand All @@ -48,9 +46,7 @@
from pip.baseparser import ConfigOptionParser, UpdatingDefaultsHelpFormatter
from pip.commands import get_summaries, get_similar_commands
from pip.commands import commands_dict
from pip._vendor.requests.packages.urllib3.exceptions import (
InsecureRequestWarning,
)
from pip._vendor.urllib3.exceptions import InsecureRequestWarning


# assignment for flake8 to be happy
Expand Down
4 changes: 2 additions & 2 deletions pip/_vendor/cachecontrol/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import pickle


from pip._vendor.requests.packages.urllib3.response import HTTPResponse
from pip._vendor.requests.packages.urllib3.util import is_fp_closed
from pip._vendor.urllib3.response import HTTPResponse
from pip._vendor.urllib3.util import is_fp_closed

# Replicate some six behaviour
try:
Expand Down
3 changes: 3 additions & 0 deletions pip/_vendor/certifi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .core import where, old_where

__version__ = "2018.01.18"
2 changes: 2 additions & 0 deletions pip/_vendor/certifi/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from certifi import where
print(where())
2,947 changes: 882 additions & 2,065 deletions pip/_vendor/requests/cacert.pem → pip/_vendor/certifi/cacert.pem

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions pip/_vendor/certifi/core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
certifi.py
~~~~~~~~~~
This module returns the installation location of cacert.pem.
"""
import os
import warnings


class DeprecatedBundleWarning(DeprecationWarning):
"""
The weak security bundle is being deprecated. Please bother your service
provider to get them to stop using cross-signed roots.
"""


def where():
f = os.path.dirname(__file__)

return os.path.join(f, 'cacert.pem')


def old_where():
warnings.warn(
"The weak security bundle has been removed. certifi.old_where() is now an alias "
"of certifi.where(). Please update your code to use certifi.where() instead. "
"certifi.old_where() will be removed in 2018.",
DeprecatedBundleWarning
)
return where()

if __name__ == '__main__':
print(where())
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,25 @@
# 02110-1301 USA
######################### END LICENSE BLOCK #########################

__version__ = "2.3.0"
from sys import version_info

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

def detect(aBuf):
if ((version_info < (3, 0) and isinstance(aBuf, unicode)) or
(version_info >= (3, 0) and not isinstance(aBuf, bytes))):
raise ValueError('Expected a bytes object, not a unicode object')

from . import universaldetector
u = universaldetector.UniversalDetector()
u.reset()
u.feed(aBuf)
u.close()
return u.result
def detect(byte_str):
"""
Detect the encoding 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: '
'{0}'.format(type(byte_str)))
else:
byte_str = bytearray(byte_str)
detector = UniversalDetector()
detector.feed(byte_str)
return detector.close()
386 changes: 386 additions & 0 deletions pip/_vendor/chardet/big5freq.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,20 @@
from .mbcharsetprober import MultiByteCharSetProber
from .codingstatemachine import CodingStateMachine
from .chardistribution import Big5DistributionAnalysis
from .mbcssm import Big5SMModel
from .mbcssm import BIG5_SM_MODEL


class Big5Prober(MultiByteCharSetProber):
def __init__(self):
MultiByteCharSetProber.__init__(self)
self._mCodingSM = CodingStateMachine(Big5SMModel)
self._mDistributionAnalyzer = Big5DistributionAnalysis()
super(Big5Prober, self).__init__()
self.coding_sm = CodingStateMachine(BIG5_SM_MODEL)
self.distribution_analyzer = Big5DistributionAnalysis()
self.reset()

def get_charset_name(self):
@property
def charset_name(self):
return "Big5"

@property
def language(self):
return "Chinese"
Loading

6 comments on commit 2e142d3

@xrg
Copy link

@xrg xrg commented on 2e142d3 Apr 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this commit is quite a big change (compatibility-wise), pitty that happened in only a minor version change. :(
More specifically, doing:
import requests
import pip

after this would break, as the standalone requests would conflict with the bundled one. That wouldn't happen in 9.0.2

@pradyunsg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @xrg!

Importing pip is an unsupported use of pip, which is a command line tool, that just happens to be written in Python. You can find more details at #5081.

There was an announcement made a few months back about this change. Any user of import pip should switch to using pip in a supported manner as documented or acknowledge that they're fiddling with pip's internals and act accordingly.

@xrg
Copy link

@xrg xrg commented on 2e142d3 Apr 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my case I've been trying to "read" the internals, to extract some config information: "where is the active pip config and what is the Pypi URL currently configured? "
With all respect for the work you've done so far, should we also consider a minimal API or allow an easy way to implement such "extensions" on pip?

@pfmoore
Copy link
Member

@pfmoore pfmoore commented on 2e142d3 Apr 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xrg A pip command line invocation (pip info or similar) could be added to provide this sort of information. That would be a reasonable enhancement request. Although as I'm sure you're aware the information you quote is not that simple to get - pip has multiple config locations that get merged, and allows for multiple index URLs - how to present that sort of data is something that could be thrashed out as part of designing a pip info command, though.

@pradyunsg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for the configuration, I imagine pip config in pip 10 should be able to satisfy your requirements.

@pfmoore
Copy link
Member

@pfmoore pfmoore commented on 2e142d3 Apr 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh. Sorry @pradyunsg I keep forgetting we now have pip config. Yes, that would give the information @xrg needs (apart from the name of the config file, but with pip config he shouldn't need that...)

(Apparently pip config edit --editor=echo will give the config filename. I'm not sure I'd consider that as legitimate use, though!)

Please sign in to comment.