-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Should None values in data be handled differently? #378
Comments
Good idea but we should check for |
@johtso Strange thing. I got notification about your post which begins with Ah yes, of course, forgot about 0. What about False? if (v is None) or (v is False): v = but I don't see your post from notification... |
Ah, I deleted it while reconsidering the problem :) Sorry for the confusion.. Translating |
@kennethreitz, what do you think? :) |
This should not be happening ;) |
Maybe keys with None value should not be present in the request at all? |
Looks like I've misunderstood things a bit.
So the only question is, do we want to remove keys with values of |
The only purpose of removal upon I'd like to not make any changes to the behavior of |
Yeah, I think that's probably wise. If you want keys without values in your data, convert |
If this is the case then I think it's wrong. The behavior should be consistent. |
I agree with @piotr-dobrogost, keys with |
Well, regardless of the reason it's convenient and logical.
As this issue shows this matters not only for params. Current behavior of having |
I vote that this should behave how every other browser behaves, which is to just send across an empty string. (Just spent an hour debugging this issue with James Cleary). Cal Leeming |
FYI - to anyone else who is having this issue, we hotfix'd it using the following:
|
@foxx If you want to send empty string as a value of some param you should set its value to empty string. Why should requests send |
Guess my reply is, why SHOULDN'T it? It's a 50/50 split, and really comes down to the decision of the core maintainer I guess.
You're right, I probably should have used "is None" - I'll patch our side - thanks. |
It's not 50/50 split if you take into consideration some other aspects. In case of params requests already deletes keys with value set to |
Seven months later, resolved by #805! |
Currently, if data contains
None
values they are passed on tourllib.urlencode
as normal. The behaviour ofurllib.urlencode
is to always callstr()
on the key/value.This results in the following:
To me this seems like odd behaviour. If anything it would make sense for it to result in
'key='
.One option would be to do something like
v = v or ''
before encoding the data.Alternatively exceptions could be raised if a key or value is
None
.Does this sound like something that should be changed?
The text was updated successfully, but these errors were encountered: