This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ianwremmel
Recipients ianwremmel
Date 2018-10-05.17:21:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1538760084.12.0.545547206417.issue34908@psf.upfronthosting.co.za>
In-reply-to
Content
This started as a bug report for httpie https://github.com/jakubroztocil/httpie/issues/717#issuecomment-426125261

And became a bug report for requests https://github.com/requests/requests/issues/4813

> But turned out to be an issue with Python's netrc parser:
> 
>
> it appears that auth via netrc is broken if ~/.netrc includes entries that are not exactly login/password tuples. For example, I have the following entries for circle ci and heroku:
>
> ```
>    machine api.heroku.com
>      login <redacted>
>      password <redacted>
>      method interactive
>    machine circleci.com
>      login <redacted>
> ```
>
> both of these entries prevent my entry for github.com from working with httpie (but curl works just fine).


I've used the following script to test python 2.7 and 3.7:

```
import netrc
import os.path

netrc.netrc(os.path.expanduser('~/.netrc')).authenticators('api.github.com')
```

Python 2:
```
Traceback (most recent call last):
  File "test.py", line 4, in <module>
    netrc.netrc(os.path.expanduser('~/.netrc')).authenticators('api.github.com')
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/netrc.py", line 35, in __init__
    self._parse(file, fp, default_netrc)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/netrc.py", line 117, in _parse
    file, lexer.lineno)
netrc.NetrcParseError: bad follower token 'method' (/Users/ian/.netrc, line 7)
````

Python 3:
```
Traceback (most recent call last):
  File "test.py", line 4, in <module>
    netrc.netrc(os.path.expanduser('~/.netrc')).authenticators('api.github.com')
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/netrc.py", line 30, in __init__
    self._parse(file, fp, default_netrc)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/netrc.py", line 111, in _parse
    file, lexer.lineno)
netrc.NetrcParseError: bad follower token 'method' (/Users/ian/.netrc, line 7)
```
History
Date User Action Args
2018-10-05 17:21:24ianwremmelsetrecipients: + ianwremmel
2018-10-05 17:21:24ianwremmelsetmessageid: <1538760084.12.0.545547206417.issue34908@psf.upfronthosting.co.za>
2018-10-05 17:21:24ianwremmellinkissue34908 messages
2018-10-05 17:21:23ianwremmelcreate