-
Notifications
You must be signed in to change notification settings - Fork 160
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
Allow numpy values in query #945
Comments
Relevant code: Lines 935 to 951 in ea09409
|
I don't think we should accept types that we don't know how to correctly represent as strings. Same as booleans and other unobvious contexts. |
Yeah, we'd need to import numpy for this to work, which doesn't seem reasonable. In the current state, numpy values are just custom, unique types that mean nothing to yarl. |
However numpy.int16, numpy.int32 etc. are subclasses of numbers.Number.
Or may be (at the worst) to delete checking for int types completely and try to convert to int forcibly after the all other type checking (and we would catch an exception if custom type can not be convert to int type). It would be valuable to allow numpy values because numpy is widely used. |
The thing is that URLs are strings and they only operate on strings. Accepting |
Oh, weird, when I tested it, it came up False. I've just upgraded to latest version and retested and it is True, maybe something changed in a recent release (or maybe I just tested it incorrectly...).
Well, urllib.parse.urlencode() seems to accept anything.
Reserved characters are escaped:
Personally, I don't mind either way, as long as it doesn't allow injecting arguments. |
Requests internally uses urllib3 and accepts numpy values (as well as boolean by the way). Standalone urllib3 also do it:
|
Okay, I guess we could make an exception for |
Describe the bug
Passing a numpy integer value (numpy.int16, numpy.int32 , numpy.int64 etc.) in dictionary as GET request 'params' gives an TypeError: Invalid variable type: value should be str, int or float, got 12345 of type <class 'numpy.int16'>
But it works properly if passing numpy integer values in a dictionary as POST request 'data'.
To Reproduce
Place any numpy integer value (numpy.int16, numpy.int32 , numpy.int64 etc.) in GET request 'params'
Expected behavior
To accept numpy integer type in GET request 'params'
Logs/tracebacks
Python Version
aiohttp Version
multidict Version
yarl Version
OS
Windows
Related component
Client
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: