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 xtreak
Recipients bbayles, skip.montanaro, xiang.zhang, xtreak
Date 2018-07-17.10:14:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1531822476.38.0.56676864532.issue34132@psf.upfronthosting.co.za>
In-reply-to
Content
This seems to have been introduced with commit : 1df0f214a9fdb4dde7506576b144cf6a7fd01b65 before which it was working fine.

Testing shows the error from 1df0f214a9fdb4dde7506576b144cf6a7fd01b65 and above. I have checked out only versions of Lib/netrc.py and I think this doesn't require a rebuild of Python.

➜  cpython git:(master) $ git log --oneline --format="%h" Lib/netrc.py > commits.txt # Get all commits to test the changes
➜  cpython git:(master) ✗ ./python netrc_foo_tester.py

netrc_foo_tester.py is attached with the message which basically does the below using Python for every commit. netrc_foo.py contains the actual test of parsing two files.

➜  cpython git:(master) ✗ ./python
Python 3.8.0a0 (heads/master:35c0809, Jul 16 2018, 10:29:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

➜ cpython git:(master) ✗ cat netrc_foo.py
import netrc

rc = netrc.netrc(file="netrc-comment-blank")
rc = netrc.netrc(file="netrc-blank-comment")

➜  cpython git:(master) ✗ git reset --quiet HEAD . && git checkout . && git checkout be19ed7 Lib/netrc.py && ./python netrc_foo.py
netrc_foo.py:2: ResourceWarning: unclosed file <_io.TextIOWrapper name='netrc-comment-blank' mode='r' encoding='UTF-8'>
  rc = netrc.netrc(file="netrc-comment-blank")
netrc_foo.py:3: ResourceWarning: unclosed file <_io.TextIOWrapper name='netrc-blank-comment' mode='r' encoding='UTF-8'>
  rc = netrc.netrc(file="netrc-blank-comment")
➜  cpython git:(master) ✗ git reset --quiet HEAD . && git checkout . && git checkout c12a813 Lib/netrc.py && ./python netrc_foo.py
➜  cpython git:(master) ✗ git reset --quiet HEAD . && git checkout . && git checkout 78a1a15 Lib/netrc.py && ./python netrc_foo.py
➜  cpython git:(master) ✗ git reset --quiet HEAD . && git checkout . && git checkout 1df0f21 Lib/netrc.py && ./python netrc_foo.py
Traceback (most recent call last):
  File "netrc_foo.py", line 3, in <module>
    rc = netrc.netrc(file="netrc-blank-comment")
  File "/home/cpython/Lib/netrc.py", line 32, in __init__
    self._parse(file, fp)
  File "/home/cpython/Lib/netrc.py", line 65, in _parse
    "bad toplevel token %r" % tt, file, lexer.lineno)
netrc.NetrcParseError: bad toplevel token 'Comment' (netrc-blank-comment, line 2)

I hope the above approach is correct.

Thanks
History
Date User Action Args
2018-07-17 10:14:36xtreaksetrecipients: + xtreak, skip.montanaro, xiang.zhang, bbayles
2018-07-17 10:14:36xtreaksetmessageid: <1531822476.38.0.56676864532.issue34132@psf.upfronthosting.co.za>
2018-07-17 10:14:36xtreaklinkissue34132 messages
2018-07-17 10:14:36xtreakcreate