Imported Upstream version 36.8.0 upstream/36.8.0
authorDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 14 Jan 2019 01:37:16 +0000 (10:37 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 14 Jan 2019 01:37:16 +0000 (10:37 +0900)
CHANGES.rst
setup.cfg
setup.py
setuptools/package_index.py
setuptools/ssl_support.py

index 9ca450318b11848ec105d510843b95d17f8ad4ce..65ab85bc6e93c62cdc6c6df04c38167b3141b7c3 100644 (file)
@@ -1,3 +1,9 @@
+v36.8.0
+-------
+
+* #1190: In SSL support for package index operations, use SNI
+  where available.
+
 v36.7.3
 -------
 
index 850f5762641795659a302ec1ece77886c55a0cf5..8da91de23ccd3d0dd3b1a9cabbc69ac124ee08b2 100755 (executable)
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 36.7.3
+current_version = 36.8.0
 commit = True
 tag = True
 
index b5e7879bf14970d2f1f9be80ce267d2b1e7e0afc..c6dfc79515cbbffda68c049f518bc062b1fd8517 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -89,7 +89,7 @@ def pypi_link(pkg_filename):
 
 setup_params = dict(
     name="setuptools",
-    version="36.7.3",
+    version="36.8.0",
     description="Easily download, build, install, upgrade, and uninstall "
         "Python packages",
     author="Python Packaging Authority",
index a6363b1856c78d54ce86e64e506bc75ad38b63bf..e0aeb309d73ec32651aa8f3fd75378506a475404 100755 (executable)
@@ -141,7 +141,7 @@ def distros_for_filename(filename, metadata=None):
 def interpret_distro_name(
         location, basename, metadata, py_version=None, precedence=SOURCE_DIST,
         platform=None
-        ):
+):
     """Generate alternative interpretations of a source distro name
 
     Note: if `location` is a filesystem filename, you should call
@@ -292,7 +292,7 @@ class PackageIndex(Environment):
     def __init__(
             self, index_url="https://pypi.python.org/simple", hosts=('*',),
             ca_bundle=None, verify_ssl=True, *args, **kw
-            ):
+    ):
         Environment.__init__(self, *args, **kw)
         self.index_url = index_url + "/" [:not index_url.endswith('/')]
         self.scanned_urls = {}
@@ -346,7 +346,8 @@ class PackageIndex(Environment):
 
         base = f.url  # handle redirects
         page = f.read()
-        if not isinstance(page, str):  # We are in Python 3 and got bytes. We want str.
+        if not isinstance(page, str):
+            # In Python 3 and got bytes but want str.
             if isinstance(f, urllib.error.HTTPError):
                 # Errors have no charset, assume latin1:
                 charset = 'latin-1'
@@ -381,8 +382,9 @@ class PackageIndex(Environment):
         is_file = s and s.group(1).lower() == 'file'
         if is_file or self.allows(urllib.parse.urlparse(url)[1]):
             return True
-        msg = ("\nNote: Bypassing %s (disallowed host; see "
-            "http://bit.ly/1dg9ijs for details).\n")
+        msg = (
+            "\nNote: Bypassing %s (disallowed host; see "
+            "http://bit.ly/2hrImnY for details).\n")
         if fatal:
             raise DistutilsError(msg % url)
         else:
@@ -500,15 +502,16 @@ class PackageIndex(Environment):
         """
         checker is a ContentChecker
         """
-        checker.report(self.debug,
+        checker.report(
+            self.debug,
             "Validating %%s checksum for %s" % filename)
         if not checker.is_valid():
             tfp.close()
             os.unlink(filename)
             raise DistutilsError(
                 "%s validation failed for %s; "
-                "possible download problem?" % (
-                                checker.hash.name, os.path.basename(filename))
+                "possible download problem?"
+                % (checker.hash.name, os.path.basename(filename))
             )
 
     def add_find_links(self, urls):
@@ -536,7 +539,8 @@ class PackageIndex(Environment):
         if self[requirement.key]:  # we've seen at least one distro
             meth, msg = self.info, "Couldn't retrieve index page for %r"
         else:  # no distros seen for this name, might be misspelled
-            meth, msg = (self.warn,
+            meth, msg = (
+                self.warn,
                 "Couldn't find index page for %r (maybe misspelled?)")
         meth(msg, requirement.unsafe_name)
         self.scan_all()
@@ -577,8 +581,7 @@ class PackageIndex(Environment):
 
     def fetch_distribution(
             self, requirement, tmpdir, force_scan=False, source=False,
-            develop_ok=False, local_index=None
-            ):
+            develop_ok=False, local_index=None):
         """Obtain a distribution suitable for fulfilling `requirement`
 
         `requirement` must be a ``pkg_resources.Requirement`` instance.
@@ -609,12 +612,19 @@ class PackageIndex(Environment):
 
                 if dist.precedence == DEVELOP_DIST and not develop_ok:
                     if dist not in skipped:
-                        self.warn("Skipping development or system egg: %s", dist)
+                        self.warn(
+                            "Skipping development or system egg: %s", dist,
+                        )
                         skipped[dist] = 1
                     continue
 
-                if dist in req and (dist.precedence <= SOURCE_DIST or not source):
-                    dist.download_location = self.download(dist.location, tmpdir)
+                test = (
+                    dist in req
+                    and (dist.precedence <= SOURCE_DIST or not source)
+                )
+                if test:
+                    loc = self.download(dist.location, tmpdir)
+                    dist.download_location = loc
                     if os.path.exists(dist.download_location):
                         return dist
 
@@ -704,7 +714,7 @@ class PackageIndex(Environment):
     def _download_to(self, url, filename):
         self.info("Downloading %s", url)
         # Download the file
-        fp, info = None, None
+        fp = None
         try:
             checker = HashChecker.from_url(url)
             fp = self.open_url(strip_fragment(url))
@@ -1103,7 +1113,8 @@ def local_open(url):
                 f += '/'
             files.append('<a href="{name}">{name}</a>'.format(name=f))
         else:
-            tmpl = ("<html><head><title>{url}</title>"
+            tmpl = (
+                "<html><head><title>{url}</title>"
                 "</head><body>{files}</body></html>")
             body = tmpl.format(url=url, files='\n'.join(files))
         status, message = 200, "OK"
index 72b18ef2664a7a38d510e8014b84ae260b016ace..6362f1f426910ab36f8b26d1382adf08f43ba992 100644 (file)
@@ -186,9 +186,14 @@ class VerifyingHTTPSConn(HTTPSConnection):
         else:
             actual_host = self.host
 
-        self.sock = ssl.wrap_socket(
-            sock, cert_reqs=ssl.CERT_REQUIRED, ca_certs=self.ca_bundle
-        )
+        if hasattr(ssl, 'create_default_context'):
+            ctx = ssl.create_default_context(cafile=self.ca_bundle)
+            self.sock = ctx.wrap_socket(sock, server_hostname=actual_host)
+        else:
+            # This is for python < 2.7.9 and < 3.4?
+            self.sock = ssl.wrap_socket(
+                sock, cert_reqs=ssl.CERT_REQUIRED, ca_certs=self.ca_bundle
+            )
         try:
             match_hostname(self.sock.getpeercert(), actual_host)
         except CertificateError: