-
Notifications
You must be signed in to change notification settings - Fork 306
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
Do not send empty fields in the upload form data #1203
Conversation
No behavior changes intended. Just cleaning up some loose ends.
The underlying library strips none values if I remember correctly. I agree it's a strange behavior to rely upon but as the author, I have no intention of breaking that |
What is that is this context? |
https://toolbelt.readthedocs.io/en/latest/uploading-data.html#streaming-multipart-data-encoder In other words: The thing that encodes the request data to PyPI which should be stripping out any None values thus meaning nothing is sent. I agree that just not including the field is just as fine. But the different here is not in not sending it to PyPI, it's just in not including it in the dictionary. |
Sorry to insist, but this comment in the code made me believe otherwise: Lines 274 to 278 in 0605ef0
And testing suggests that fields with >>> from requests_toolbelt.multipart.encoder import MultipartEncoder
>>> MultipartEncoder(fields=[('foo', None)]).to_string()
b'--f206243b92be45efa8c60a7c05060c28\r\nContent-Disposition: form-data; name="foo"\r\n\r\n\r\n--f206243b92be45efa8c60a7c05060c28--\r\n' |
Hm, that's a bug in the Encoder but that will be hard to fix at this point, so this makes more sense in that case |
Thanks for the review and for merging, @sigmavirus24
I'm not entirely sure it is a bug. It has been ages since I had to deal with web-related stuff, but I have some vague recollection of empty fields in form data to not be an unusual occurrence, where the mere presence of the field in the data has a meaning. I don't know why someone would decide to model them as |
Requests has always stripped None from anything except the |
No behavior changes intended. Just cleaning up some loose ends.