Repository: pypa/twine

Issue:
Requests 2.9.0 and requests-toolbelt < 0.5.1 break uploading
We need to bump the lower limit on our dependency of requests-toolbelt.

See also: https://github.com/sigmavirus24/requests-toolbelt/issues/117

Discussion:

Patch:
diff --git a/README.rst b/README.rst
index ab4baa4..9b8f0bb 100644
--- a/README.rst
+++ b/README.rst
@@ -54,15 +54,15 @@ Usage
 
 1. Create some distributions in the normal way:
 
-   .. code-block:: bash
+.. code-block:: bash
 
-       $ python setup.py sdist bdist_wheel
+    $ python setup.py sdist bdist_wheel
 
 2. Upload with twine:
 
-   .. code-block:: bash
+.. code-block:: bash
 
-       $ twine upload dist/*
+    $ twine upload dist/*
 
 3. Done!
 
@@ -73,10 +73,8 @@ Options
 .. code-block:: bash
 
     $ twine upload -h
-
-    usage: twine upload [-h] [-r REPOSITORY] [-s] [--sign-with SIGN_WITH]
-                        [-i IDENTITY] [-u USERNAME] [-p PASSWORD] [-c COMMENT]
-                        [--config-file CONFIG_FILE] [--skip-existing]
+    usage: twine upload [-h] [-r REPOSITORY] [-s] [-i IDENTITY] [-u USERNAME]
+                        [-p PASSWORD] [-c COMMENT]
                         dist [dist ...]
 
     positional arguments:
@@ -87,10 +85,8 @@ Options
     optional arguments:
       -h, --help            show this help message and exit
       -r REPOSITORY, --repository REPOSITORY
-                            The repository to upload the files to (default: pypi)
+                            The repository to upload the files to
       -s, --sign            Sign files to upload using gpg
-      --sign-with SIGN_WITH
-                            GPG program used to sign uploads (default: gpg)
       -i IDENTITY, --identity IDENTITY
                             GPG identity used to sign files
       -u USERNAME, --username USERNAME
@@ -99,9 +95,8 @@ Options
                             The password to authenticate to the repository with
       -c COMMENT, --comment COMMENT
                             The comment to include with the distribution file
-      --config-file CONFIG_FILE
+      --config-file FILE    
                             The .pypirc config file to use
-      --skip-existing       Continue uploading files if one already exists
 
 
 Resources
diff --git a/docs/changelog.rst b/docs/changelog.rst
index 9ad96d0..d16cada 100644
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -4,12 +4,10 @@
 Changelog
 =========
 
-* :release:`1.7.0 <TBD>`
+* :release:`1.6.5 <2015-12-16>`
 
-  * :feature:`142` Support ``--cert`` and ``--client-cert`` command-line flags
-    and config file options for feature parity with pip. This allows users to
-    verify connections to servers other than PyPI (e.g., local package
-    repositories) with different certificates.
+  * :bug:`155` Bump requests-toolbelt version to ensure we avoid
+    ConnectionErrors
 
 * :release:`1.6.4 <2015-10-27>`
 
diff --git a/setup.py b/setup.py
index 6053a66..2af1dcc 100644
--- a/setup.py
+++ b/setup.py
@@ -21,7 +21,7 @@ import twine
 install_requires = [
     "pkginfo >= 1.0",
     "requests >= 2.3.0",
-    "requests-toolbelt >= 0.4.0",
+    "requests-toolbelt >= 0.5.1",
     "setuptools >= 0.7.0",
 ]
 
diff --git a/twine/__init__.py b/twine/__init__.py
index e8f83e4..2549002 100644
--- a/twine/__init__.py
+++ b/twine/__init__.py
@@ -23,7 +23,7 @@ __title__ = "twine"
 __summary__ = "Collection of utilities for interacting with PyPI"
 __uri__ = "https://github.com/pypa/twine"
 
-__version__ = "1.6.4"
+__version__ = "1.6.5"
 
 __author__ = "Donald Stufft and individual contributors"
 __email__ = "donald@stufft.io"
diff --git a/twine/commands/register.py b/twine/commands/register.py
index 16eece0..6be8cc8 100644
--- a/twine/commands/register.py
+++ b/twine/commands/register.py
@@ -23,8 +23,7 @@ from twine.repository import Repository
 from twine import utils
 
 
-def register(package, repository, username, password, comment, config_file,
-             cert, client_cert):
+def register(package, repository, username, password, comment, config_file):
     config = utils.get_repository_from_config(config_file, repository)
     config["repository"] = utils.normalize_repository_url(
         config["repository"]
@@ -34,12 +33,8 @@ def register(package, repository, username, password, comment, config_file,
 
     username = utils.get_username(username, config)
     password = utils.get_password(password, config)
-    ca_cert = utils.get_cacert(cert, config)
-    client_cert = utils.get_clientcert(client_cert, config)
 
     repository = Repository(config["repository"], username, password)
-    repository.set_certificate_authority(ca_cert)
-    repository.set_client_certificate(client_cert)
 
     if not os.path.exists(package):
         raise exc.PackageNotFound(
@@ -83,17 +78,6 @@ def main(args):
         default="~/.pypirc",
         help="The .pypirc config file to use",
     )
-    parser.add_argument(
-        "--cert",
-        metavar="path",
-        help="Path to alternate CA bundle",
-    )
-    parser.add_argument(
-        "--client-cert",
-        metavar="path",
-        help="Path to SSL client certificate, a single file containing the "
-             "private key and the certificate in PEM forma",
-    )
     parser.add_argument(
         "package",
         metavar="package",
diff --git a/twine/commands/upload.py b/twine/commands/upload.py
index f194d8a..2bd4a52 100644
--- a/twine/commands/upload.py
+++ b/twine/commands/upload.py
@@ -62,7 +62,7 @@ def skip_upload(response, skip_existing, package):
 
 
 def upload(dists, repository, sign, identity, username, password, comment,
-           sign_with, config_file, skip_existing, cert, client_cert):
+           sign_with, config_file, skip_existing):
     # Check that a nonsensical option wasn't given
     if not sign and identity:
         raise ValueError("sign must be given along with identity")
@@ -85,12 +85,8 @@ def upload(dists, repository, sign, identity, username, password, comment,
 
     username = utils.get_username(username, config)
     password = utils.get_password(password, config)
-    ca_cert = utils.get_cacert(cert, config)
-    client_cert = utils.get_clientcert(client_cert, config)
 
     repository = Repository(config["repository"], username, password)
-    repository.set_certificate_authority(ca_cert)
-    repository.set_client_certificate(client_cert)
 
     for filename in uploads:
         package = PackageFile.from_filename(filename, comment)
@@ -171,17 +167,6 @@ def main(args):
         action="store_true",
         help="Continue uploading files if one already exists",
     )
-    parser.add_argument(
-        "--cert",
-        metavar="path",
-        help="Path to alternate CA bundle",
-    )
-    parser.add_argument(
-        "--client-cert",
-        metavar="path",
-        help="Path to SSL client certificate, a single file containing the "
-             "private key and the certificate in PEM forma",
-    )
     parser.add_argument(
         "dists",
         nargs="+",
diff --git a/twine/repository.py b/twine/repository.py
index ac441f5..ae57821 100644
--- a/twine/repository.py
+++ b/twine/repository.py
@@ -41,14 +41,6 @@ class Repository(object):
                     data_to_send.append((key, item))
         return data_to_send
 
-    def set_certificate_authority(self, cacert):
-        if cacert:
-            self.session.verify = cacert
-
-    def set_client_certificate(self, clientcert):
-        if clientcert:
-            self.session.cert = clientcert
-
     def register(self, package):
         data = package.metadata_dictionary()
         data.update({
diff --git a/twine/utils.py b/twine/utils.py
index d8771ce..db49d14 100644
--- a/twine/utils.py
+++ b/twine/utils.py
@@ -116,15 +116,14 @@ def normalize_repository_url(url):
     return urlunparse(parsed)
 
 
-def get_userpass_value(cli_value, config, key, prompt_strategy=None):
+def get_userpass_value(cli_value, config, key, prompt_strategy):
     """Gets the username / password from config.
 
     Uses the following rules:
 
     1. If it is specified on the cli (`cli_value`), use that.
     2. If `config[key]` is specified, use that.
-    3. If `prompt_strategy`, prompt using `prompt_strategy`.
-    4. Otherwise return None
+    3. Otherwise prompt using `prompt_strategy`.
 
     :param cli_value: The value supplied from the command line or `None`.
     :type cli_value: unicode or `None`
@@ -141,10 +140,8 @@ def get_userpass_value(cli_value, config, key, prompt_strategy=None):
         return cli_value
     elif config.get(key):
         return config[key]
-    elif prompt_strategy:
-        return prompt_strategy()
     else:
-        return None
+        return prompt_strategy()
 
 
 def password_prompt(prompt_text):  # Always expects unicode for our own sanity
@@ -164,11 +161,3 @@ get_password = functools.partial(
     key='password',
     prompt_strategy=password_prompt('Enter your password: '),
 )
-get_cacert = functools.partial(
-    get_userpass_value,
-    key='ca_cert',
-)
-get_clientcert = functools.partial(
-    get_userpass_value,
-    key='client_cert',
-)


Test patch:
diff --git a/tests/test_repository.py b/tests/test_repository.py
index 684f403..3b8d84b 100644
--- a/tests/test_repository.py
+++ b/tests/test_repository.py
@@ -47,29 +47,3 @@ def test_iterables_are_flattened():
     tuples = repository.Repository._convert_data_to_list_of_tuples(data)
     assert tuples == [('platform', 'UNKNOWN'),
                       ('platform', 'ANOTHERPLATFORM')]
-
-
-def test_set_client_certificate():
-    repo = repository.Repository(
-        repository_url='https://pypi.python.org/pypi',
-        username='username',
-        password='password',
-    )
-
-    assert repo.session.cert is None
-
-    repo.set_client_certificate(('/path/to/cert', '/path/to/key'))
-    assert repo.session.cert == ('/path/to/cert', '/path/to/key')
-
-
-def test_set_certificate_authority():
-    repo = repository.Repository(
-        repository_url='https://pypi.python.org/pypi',
-        username='username',
-        password='password',
-    )
-
-    assert repo.session.verify is True
-
-    repo.set_certificate_authority('/path/to/cert')
-    assert repo.session.verify == '/path/to/cert'
diff --git a/tests/test_upload.py b/tests/test_upload.py
index 596de80..7f99510 100644
--- a/tests/test_upload.py
+++ b/tests/test_upload.py
@@ -78,7 +78,6 @@ def test_get_config_old_format(tmpdir):
     try:
         upload.upload(dists=dists, repository="pypi", sign=None, identity=None,
                       username=None, password=None, comment=None,
-                      cert=None, client_cert=None,
                       sign_with=None, config_file=pypirc, skip_existing=False)
     except KeyError as err:
         assert err.args[0] == (