Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-34132: Fix netrc parsing regression #8360

Closed
wants to merge 3 commits into from

Conversation

bbayles
Copy link
Contributor

@bbayles bbayles commented Jul 21, 2018

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 added the type-bug An unexpected behavior, bug, or error label Oct 29, 2018
@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Oct 29, 2018

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.

@bbayles bbayles closed this Oct 29, 2018
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