[issue29895] Distutils blows up with an incorrect pypirc, should be caught

Berker Peksag report at bugs.python.org
Sun May 14 02:33:07 EDT 2017


Berker Peksag added the comment:

Thanks for the report, Tommy. I think the configparser exception is pretty descriptive here. You had a .pypirc file like the following:

    [distutils]
    index-servers = 
      pypi
      global

    [pypi]
    username:spam
    password:eggs

You passed -r global and you got:

    Traceback (most recent call last):
      ...
    ConfigParser.NoSectionError: No section: 'global'

Which says you don't have a section named 'global' in your .pypirc.

There are three options here:

a) do nothing
b) catch configparser.NoSectionError and raise a distutils exception with better wording. Since we don't have DistutilsConfigError, I'm not sure which one is more appropriate here.
c) ignore configparser.NoSectionError if server name cannot be found in sections in PyPIRCCommand._read_pypirc(). IMO this is the worst option.

Here is a test case to demonstrate the problem described at the SO question.

----------
keywords: +patch
nosy: +berker.peksag
versions: +Python 3.5, Python 3.6, Python 3.7
Added file: http://bugs.python.org/file46863/issue29895_test.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29895>
_______________________________________


More information about the Python-bugs-list mailing list