You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Some DateTimeTest format tests fail on the upcoming Fedora 39 #84763
The problem is in DateTime.TryFormat with Utf-8. This assumes all date/time pattern characters are ascii which is not the case as CLDR started to use U+202F as the space character. The following line should convert the character to Utf-8 and store it to the buffer instead of just casting it.
I had tried to reproduce the issue in a Fedora 38, and a Fedora 39 container yesterday and to my surprise it didn't reproduce.
The problem is in DateTime.TryFormat with Utf-8. This assumes all date/time pattern characters are ascii which is not the case as CLDR started to use U+202F as the space character. The following line should convert the character to Utf-8 and store it to the buffer instead of just casting it.
Thanks for pointing me to the problem.
This matches with the failures: they show / (0x2F) which is the lower byte of U+202F:
@tarekgh the parser issues occur when a non-breaking space occurs in the format string.
The tests fail for AllowWhiteSpaces because the parser expects skipped whitespace to match with regular spaces only.
We can allow it to match it also with the non-breaking spaces.
What is probably not covered by any tests: what should happen (without AllowWhiteSpaces) when the format string has a non-breaking space, and the string being parsed has a regular, or a different type of non-breaking space at that position?
You may use Char.IsWhiteSpace instead of checking every character manually. And if you confirm this will fix the FormatException, then it should be good and go ahead open the PR. Thanks for the help with this issue.
Activity
tarekgh commentedon Apr 18, 2023
The problem is in DateTime.TryFormat with
Utf-8. This assumes all date/time pattern characters are ascii which is not the case as CLDR started to useU+202Fas the space character. The following line should convert the character to Utf-8 and store it to the buffer instead of just casting it.runtime/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeFormat.cs
Line 730 in 9aefa9d
tmds commentedon Apr 18, 2023
I had tried to reproduce the issue in a Fedora 38, and a Fedora 39 container yesterday and to my surprise it didn't reproduce.
Thanks for pointing me to the problem.
This matches with the failures: they show
/(0x2F) which is the lower byte ofU+202F:tarekgh commentedon Apr 18, 2023
I am able to produce the issue on edora 39. I just used
Fedora:39docker imagetmds commentedon Apr 18, 2023
Let me try again.
I'm using the image from registry.fedoraproject.org/fedora , which has a sha ae8f1aaa5e2b for Fedora 39.
Are we using the same one?
tarekgh commentedon Apr 18, 2023
I just did
docker pull fedora:39and then manually added all needed dependencies to build the runtime repo.tmds commentedon Apr 18, 2023
We're using a different image:
I'm going to try building in the Docker Hub image, and see if that reproduces the issue for me as well.
2 remaining items
tmds commentedon Apr 18, 2023
Aha, this does it:
tarekgh commentedon Apr 18, 2023
right, don't keep
Clocale as default. We use Invariant culture at that time which will not haveU+202Fin the time formats.tmds commentedon Apr 19, 2023
@tarekgh the parser issues occur when a non-breaking space occurs in the format string.
The tests fail for
AllowWhiteSpacesbecause the parser expects skipped whitespace to match with regular spaces only.We can allow it to match it also with the non-breaking spaces.
What is probably not covered by any tests: what should happen (without
AllowWhiteSpaces) when the format string has a non-breaking space, and the string being parsed has a regular, or a different type of non-breaking space at that position?(edit:) or is this fully covered by:
runtime/src/libraries/System.Runtime/tests/System/DateTimeTests.cs
Lines 2021 to 2023 in 33b1869
tarekgh commentedon Apr 19, 2023
@tmds are you willing to open a PR for it? If not, I'll take care with it.
tmds commentedon Apr 19, 2023
I was working on this patch: main...tmds:runtime:parse_nbsp.
This fixes the
FormatExceptionsI had mentioned in #84963 (comment).If this looks like the way to go, I'll open up a PR.
tarekgh commentedon Apr 19, 2023
You may use
Char.IsWhiteSpaceinstead of checking every character manually. And if you confirm this will fix theFormatException, then it should be good and go ahead open the PR. Thanks for the help with this issue.tmds commentedon Apr 20, 2023
Reopen to track fixing the FormatExceptions.