-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
strings: broken backward compatibility in 1.12 #31121
Comments
Update: the bug seems to be introduced by https://go-review.googlesource.com/c/go/+/131495 |
Thanks for the report. I'm tentatively putting this into the 1.13 milestone, pending investigation. It would be nice to have a self-contained example that shows how the new behaviour is different from the old, and why this is causing tests breakage. cc @martisch, author of that CL, in the meantime. |
@ALTree I still trying to figure out what exactly triggers that bug, but no luck for now. anyway, for now only solution for me is to swap toLower implementation with vendored one in the router core using build constraints. |
The difference is how invalid UTF8 sequences are treated and this is WAI and wont change back. They now will always be converted to RuneRrror runes. Before they were only converted to RuneError runes when there also was another change e.g. upper case character converted to lower case. Which was inconsistent and a bug. The new behaviour is consistent and always converts invalid sequences. For the noted examples such as https://github.com/julienschmidt/httprouter a bug was filed before go1.12 release that the tests will fail as the package assumes the old behaviour. julienschmidt/httprouter#263 Some of the problems seen with package tests breaking happen when the packages incorrectly assume that they can convert strings byte by byte which the new behaviour converts into RuneErrors for non ASCII characters and this only worked accidentally before when not needing to convert part of the string with invalid sequences. For example: go-openapi/swag#26 |
Of course there can still be a bug in ToLower that converts a string incorrectly. For that it would be good to have an example string that can be passed to ToLower as a minimal reproducer to investigate. |
Timed out in state WaitingForInfo. Closing. (I am just a bot, though. Please speak up if this is a mistake or you have the requested information.) |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Example 1.
Example 2: the exactly same steps, but with github.com/gramework/gramework before hotfix
Example 3: or https://github.com/julienschmidt/httprouter
Example 4: or https://github.com/buaazp/fasthttprouter
Example ∞: or any program that relies on lowering UTF-8 characters.
What did you expect to see?
Tests pass on 1.12 without copying two functions from the standard strings package.
What did you see instead?
Broken tests and projects that can be fixed only by vendoring stdlib functions, which is at least strange keeping in mind the backward compatibility promise.
The text was updated successfully, but these errors were encountered: