diff --git a/AUTHORS b/AUTHORS index 9f4cc916..74456d69 100644 --- a/AUTHORS +++ b/AUTHORS @@ -13,3 +13,4 @@ Tom Myers Rodrigue Cloutier Tyrel Souza (https://tyrelsouza.com) Adam Talsma +Jens Diemer (http://jensdiemer.de/) diff --git a/tests/test_upload.py b/tests/test_upload.py index f42c8bcc..a42f5f90 100644 --- a/tests/test_upload.py +++ b/tests/test_upload.py @@ -11,6 +11,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import unicode_literals + +import os +import textwrap + import pretend import pytest @@ -72,3 +77,26 @@ def test_sign_file_with_identity(monkeypatch): args = ['gpg', '--detach-sign', '--local-user', 'identity', '-a', 'my_file.tar.gz'] assert replaced_check_call.calls == [pretend.call(args)] + + +def test_get_config_old_format(tmpdir): + pypirc = os.path.join(str(tmpdir), ".pypirc") + + with open(pypirc, "w") as fp: + fp.write(textwrap.dedent(""" + [server-login] + username:foo + password:bar + """)) + + try: + upload.upload(dists="foo", repository="pypi", sign=None, identity=None, + username=None, password=None, comment=None, + sign_with=None, config_file=pypirc) + except KeyError as err: + assert err.args[0] == ( + "Missing 'pypi' section from the configuration file.\n" + "Maybe you have a out-dated '{0}' format?\n" + "more info: " + "https://docs.python.org/distutils/packageindex.html#pypirc\n" + ).format(pypirc) diff --git a/twine/commands/upload.py b/twine/commands/upload.py index 8f87d505..4cc1d653 100644 --- a/twine/commands/upload.py +++ b/twine/commands/upload.py @@ -114,11 +114,16 @@ def upload(dists, repository, sign, identity, username, password, comment, try: config = get_config(config_file)[repository] except KeyError: - raise KeyError( - "Missing '{0}' section from the configuration file".format( - repository, - ), + msg = ( + "Missing '{repo}' section from the configuration file.\n" + "Maybe you have a out-dated '{cfg}' format?\n" + "more info: " + "https://docs.python.org/distutils/packageindex.html#pypirc\n" + ).format( + repo=repository, + cfg=config_file ) + raise KeyError(msg) parsed = urlparse(config["repository"]) if parsed.netloc in ["pypi.python.org", "testpypi.python.org"]: