-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
iter_lines is still broken? #5540
Comments
I still don't understand your problem but I think you have unrealistic expectations of what iter_lines does. Your issue isn't cogent enough for me to make sense of it and sounds like you're having trouble using the API which makes this appropriate for StackOverflow. You've not identified a clear bug (from what little I can understand in your issue) with the documented API |
I expect that
and with the same file
Should be equivalent file So I use an explicit single byte delimiter "\n", and expect everything to be fine. But in this case internals begins to be used I see this is an old known issue. Here I see in the comments to the code
so this is both a description of the problem and a question - why not fix this aspect for versions 2.x? I don't see any breaking changes here. the function will stop producing empty strings that it shouldn't already. And I will be able to use built in |
3.0 is never happening, so it won't be backported to 2.x
I'm not surprised. Unfortunately a lot of things are incredibly closely attached to the current behaviour of this library and even if we can say "Well they shouldn't be relying on that" it would still break those folks and would be backwards incompatible as a result. The unfortunate reality is that you and I can't predict every way that someone uses this library. Just because you can't see a reason for using it that way, doesn't mean someone is and strong backwards-compatibility is important at this stage. If 3.0 were to ever happen, that would be the time to change this behaviour but 3.0 isn't happening |
I can not agree. The changes are different. And specifically, these changes do not break anything. The method generates random empty lines. And this is only a special case when the delimiter is specified
And if the method stops generating random empty lines, then will be no point in filtering, but it won't break anything It is impossible to imagine that someone would base their logic on a side property (actually a bug) of the "randomly generate empty lines" method. To base logic on a side effect of a method that can (and should) be corrected at any time is extremely dumb And for those who do not use an explicit delimiter, nothing will change at all. |
@CalPeterson ran into this same issue, and filed saulpw/visidata#1704. I agree with @vitidev that Tracking down the various PRs, it seems like the fix in #3984 was eventually merged into a proposed 3.0 branch, but as @sigmavirus24 says above, "3.0 isn't happening". So if I understand correctly, Please allow a fix for this issue to be merged into the mainline requests library. I assure you, more people are depending on the expected behavior than are depending on the broken behavior, and it is only a matter of time until they hit this bug. |
I am curious about the claim that "3.0 is never happening". It contradicts this page where it seems requests is open to major releases, just they would be infrequent: https://requests.readthedocs.io/en/latest/community/release-process/#major-releases |
I'd be happy to try to develop a fix for this issue. So long as the issue isn't fixed, it's a trap for the unwary, and the documentation should point out that it's broken. Currently the documentation actively encourages people to use |
The following might work but is untested.
|
I'll say one more thing on the question of backward compatibility. I found 82 instances of Based on a very quick assessment:
So that's 50% of actual users of this method that are currently broken, and 0% that would be rendered broken by fixing this bug. |
I don't understand.
I can't iterate "\r\n" because "\r" and "\n" can be read into different chunks.
But I can't even get solve this problem by explicitly setting the final delimiter "\n"
because if chunk end with "\r\n", then
lines = chunk.split(delimiter)
initer_lines
append empty extra line (but chunk.splitlines() not)the same problem and just with "\n" - if chunk end with delimiter, then we get an extra empty line. Which forces you to set a large buffer size if line length is unknown
So if the
split(...)
adds an extra line, why not remove it?The text was updated successfully, but these errors were encountered: