[issue35041] urllib.parse.quote safe Parameter Not Optional

2018-10-21 Thread william.ayd
william.ayd added the comment: What if we instead just raised for anything that isn't a string or a byte? The docstring for quote suggests that it should only accept str or byte objects for safe, though it doesn't enforce that:

[issue35041] urllib.parse.quote safe Parameter Not Optional

2018-10-21 Thread Ammar Askar
Ammar Askar added the comment: I agree that urllib.parse.quote("/", safe=['/']) should probably work. It looks like the reason it doesn't is because quote tries to normalize the safe iterable to ASCII characters only. As part of this it attempts to run `< 128` on each element of safe. As

[issue35041] urllib.parse.quote safe Parameter Not Optional

2018-10-21 Thread william.ayd
william.ayd added the comment: Hmm well I still personally feel that the implementation is somewhat off mores than the documentation. Specifically I think it is confusing that it accepts an empty iterable but not one containing elements. This is fine: urllib.parse.quote("/", safe=[])

[issue35041] urllib.parse.quote safe Parameter Not Optional

2018-10-21 Thread Ammar Askar
Ammar Askar added the comment: Does rewording that prior part to "safe parameter specifies an iterable of additional ASCII characters" make it less confusing? -- ___ Python tracker

[issue35041] urllib.parse.quote safe Parameter Not Optional

2018-10-21 Thread Ammar Askar
Ammar Askar added the comment: I would say so since the documentation says: safe parameter specifies additional ASCII characters None isn't really a set of ASCII characters but the empty string and empty list are. -- ___ Python tracker

[issue35041] urllib.parse.quote safe Parameter Not Optional

2018-10-21 Thread william.ayd
william.ayd added the comment: Semantics aside is it still the intended behavior that these calls should work: urllib.parse.quote("/", safe='') AND urllib.parse.quote("/", safe=[]) But that this should raise? urllib.parse.quote("/", safe=None) IMO seems counterintuitive --

[issue35041] urllib.parse.quote safe Parameter Not Optional

2018-10-21 Thread Ammar Askar
Ammar Askar added the comment: The documentation also goes on to say that its default value is '/'. It is optional in the sense that the function can be called without providing it. It doesn't mean that `None` is somehow a valid type for it. Consider the open function for example:

[issue35041] urllib.parse.quote safe Parameter Not Optional

2018-10-21 Thread william.ayd
New submission from william.ayd : The safe parameter in urllib.parse.quote is documented as optional. However, the following will raise TypeError: 'NoneType' object is not iterable: urllib.parse.quote("/", safe=None) whereas explicitly providing an iterable will allow the function to