Skip to content

bpo-34132: Fix netrc parsing regression#8360

Closed
bbayles wants to merge 3 commits into
python:masterfrom
bbayles:netrc-comments-34132-again
Closed

bpo-34132: Fix netrc parsing regression#8360
bbayles wants to merge 3 commits into
python:masterfrom
bbayles:netrc-comments-34132-again

Conversation

@bbayles

@bbayles bbayles commented Jul 21, 2018

Copy link
Copy Markdown
Contributor

This PR adds tests and a fix for the issue described in bpo-34132, a strange regression in netrc parsing.

Current versions of Python 3 to fail to parse files like this one:


# Comment
default login user password pass 

However, they can parse files like this one:


#Comment
default login user password pass 

Python 2 had no such problem - it used negative seeks instead of the lexer's line number counter. Negative seeks don't work in Python 3, but we can use absolute seeks almost as easily.
https://github.com/python/cpython/blob/2.7/Lib/netrc.py#L47-L51

I made another attempt this earlier, but this time I think I managed to avoid introducing a different regression.

https://bugs.python.org/issue34132

@serhiy-storchaka serhiy-storchaka self-requested a review October 29, 2018 08:25
@serhiy-storchaka serhiy-storchaka added the type-bug An unexpected behavior, bug, or error label Oct 29, 2018
@serhiy-storchaka

serhiy-storchaka commented Oct 29, 2018

Copy link
Copy Markdown
Member

The result of tell() for text file is not an offset in characters. It is an opaque value, and in general case you can't do arithmetic operations with it.

Rewriting the parsing code in bpo-28806 can help to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants