You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
1. Download the example app, samples/translate/main.py.
2. Edit the request such that the optional argument source=None
service.translations().list(source=None,, q=['car']).execute()
What is the expected output? What do you see instead?
Printing the request URI reveals that None is encoded as the string "None" as
opposed to excluding the relevant argument.
What version of the product are you using? On what operating system?
2.0beta8
Please provide any additional information below.
Original issue reported on code.google.com by yova...@google.com on 11 Jun 2012 at 10:21
Do not include parameters you want excluded. Supplying a parameter with a value
of None as a value has a very different meaning than not supplying the
parameter at all.
Original comment by jcgregorio@google.com on 12 Jun 2012 at 1:10
The concern more generally is that there is no distinction between the string
"None" and the null value None.
Adding this:
req = service.translations().list(source=None,, q=['car'])
print req.uri
req = service.translations().list(source='None',, q=['car'])
print req.uri
to the translations example yields the identical strings:
https://www.googleapis.com/language/translate/v2?q=car&source=None&alt=json&target=fr&key=AIzaSyBGbYmf-u_tY_gnQCzIEicOnxVL03vf9Ow
https://www.googleapis.com/language/translate/v2?q=car&source=None&alt=json&target=fr&key=AIzaSyBGbYmf-u_tY_gnQCzIEicOnxVL03vf9Ow
I haven't tested a patch() operation, but I suspect this indistinguishability
will be particularly problematic there.
Original comment by yova...@google.com on 12 Jun 2012 at 2:13
The library knows that the 'source' parameter in this case is supposed to be a
string and casts what you pass in as a string, thus you get 'None'. If it
happened to be an int it would raise an exception, since you can't cast a None
to int, so I could see adding code to raise an exception in the case of string
parameters to keep the behavior consistent.
Patch only applies to bodies of the request, and during a patch JSON
serialization will convert a None to null.
Original comment by jcgregorio@google.com on 12 Jun 2012 at 2:22
Activity
GoogleCodeExporter commentedon Mar 28, 2016
Original comment by
jcgregorio@google.comon 12 Jun 2012 at 1:10GoogleCodeExporter commentedon Mar 28, 2016
Original comment by
yova...@google.comon 12 Jun 2012 at 2:13GoogleCodeExporter commentedon Mar 28, 2016
Original comment by
jcgregorio@google.comon 12 Jun 2012 at 2:22GoogleCodeExporter commentedon Mar 28, 2016
Original comment by
yova...@google.comon 12 Jun 2012 at 2:38GoogleCodeExporter commentedon Mar 28, 2016
Original comment by
jcgregorio@google.comon 12 Jun 2012 at 2:59GoogleCodeExporter commentedon Mar 28, 2016
Original comment by
jcgregorio@google.comon 14 Jun 2012 at 7:57GoogleCodeExporter commentedon Mar 28, 2016
Original comment by
jcgregorio@google.comon 14 Jun 2012 at 8:19GoogleCodeExporter commentedon Mar 28, 2016
Original comment by
jcgregorio@google.comon 20 Jun 2012 at 4:00GoogleCodeExporter commentedon Mar 28, 2016
Original comment by
jcgregorio@google.comon 20 Jun 2012 at 4:22