Skip to content
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

raise NumberParseException on invalid number with unicode #65

Closed
houqp opened this issue Jan 5, 2016 · 2 comments
Closed

raise NumberParseException on invalid number with unicode #65

houqp opened this issue Jan 5, 2016 · 2 comments
Labels

Comments

@houqp
Copy link

houqp commented Jan 5, 2016

HI,

We just got an UnicodeDecodeError for an invalid user input: '\xe2\x80\x8b1-123-456-789'. I suggest we catch that in the library and throw out a NumberParseException.

@daviddrysdale
Copy link
Owner

That input is the byte string for the UTF-8 encoding of u'\u200b1-123-456-789' (where \u200b is ZERO WIDTH SPACE), but the library is currently expecting (on Python 2.x) to receive a valid string -- either a unicode string or a plain str string with ASCII contents.

I'll think about whether it makes sense to unilaterally assume any str input is actually UTF-8, but in the meanwhile you can probably work around the problem by ensuring you feed in unicode objects.

@houqp
Copy link
Author

houqp commented Jan 6, 2016

Good call, I will decode all the input before feeding to the library. thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants