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
Error message when comparing same string in NFC and NFD forms is not clear on Python 3 #3426
Comments
Cool bot but I don't think any of the referenced issues is related. |
its not clear what to do here, but i do indeed wonder if we should have an heuristics that adds a diff comment line when the difference character is equal when normalized |
Check if the strings are different, but the NFKD forms are the same - see wikipedia on Unicode equivalence for details and |
Hi @Zac-HD, I talked with you about this issue as part of pycon mentored sprint. Is it okay if I take over this issue? |
Go for it! |
Hey all! |
Absolutely! |
Great to see this fixed! |
If I compare same string in different Unicode normal forms the error message doesn't show any differences between them when using Python 3. For example, if I have a test like
the result I got is
which isn't very informative.
The problem is caused by
repr('hyva\u0308')
being'hyva\u0308'
which is rendered as'hyvä'
. I submitted an issue aboutrepr()
escaping combining characters (i.e. turning the result to'hyva\\u0308'
) but it was closed as invalid.In PyTest it would be possible to use
ascii()
instead ofrepr()
, but that would make all non-ASCII strings unreadable and that would be worse. I guess the best solution would be usingascii()
if strings look the same, but I have no idea how to detect that.The text was updated successfully, but these errors were encountered: