bpo-29773: Add more cases for testing string to float conversion errors. by serhiy-storchaka · Pull Request #580 · python/cpython
| # non-UTF-8 byte string | ||
| check(b'123\xbd') | ||
| # lone surrogate in Unicode string | ||
| #check('123\udca0') |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dislike commented test. Either fix it to catch UnicodeEncodeError (which would be a CPython implementation specific test), or remove it.
Maybe it's even worth it to enhance the error message for that one.
| check(b' 123 456 ') | ||
|
|
||
| # non-ascii digits | ||
| check('\u0663\u0661\u0664!') |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest '\u0663\u0661\u0664' + '!', at the first read, I understood that the error came from non-ASCII digits. Or explain that the error is on the invalid '!' character.
| # byte string with embedded NUL | ||
| check(b'123\x00') | ||
| # non-UTF-8 byte string | ||
| check(b'123\xbd') |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's worth it to factorize tests which use the "same" text and bytes string (text encoded to Latin1): all tests except of '\u0663\u0661\u0664!', no?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to be more explicit here.