[issue35544] unicode.encode docstring says return value can be unicode

2018-12-20 Thread radiocane
radiocane added the comment: >> I'll keep on finding "-> string or unicode" misleading. > How is it misleading when its true? [I promise this is the last reply: I won't waste more of your time] me: How fast does this car go? docstring: 100 km/h or 300 km/h me: actually most people use it to

[issue35544] unicode.encode docstring says return value can be unicode

2018-12-20 Thread Steven D'Aprano
Steven D'Aprano added the comment: > I'll keep on finding "-> string or unicode" misleading. How is it misleading when its true? -- ___ Python tracker ___

[issue35544] unicode.encode docstring says return value can be unicode

2018-12-20 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: You can install any codec you like and those essentially decide on what to return as type. However, the unicode methods only allow strings or unicode to be returned in Python 2. In Python 3, .encode() only allows bytes. You can still get the full codec

[issue35544] unicode.encode docstring says return value can be unicode

2018-12-20 Thread radiocane
radiocane added the comment: Given that: 1) No standard codec returns unicode 2) I consider as "most common scenario" the case where a user wants to encode a unicode object using some character encoding and get back an str-like object I'll keep on finding "-> string or unicode" misleading.

[issue35544] unicode.encode docstring says return value can be unicode

2018-12-20 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue35544] unicode.encode docstring says return value can be unicode

2018-12-20 Thread Steven D'Aprano
Steven D'Aprano added the comment: Encoding and decoding, in the most general sense, can include unicode -> unicode and bytestring -> bytestring. I can't see any standard unicode->unicode encodings in Python 2.7 https://docs.python.org/2/library/codecs.html but we can create one: py>

[issue35544] unicode.encode docstring says return value can be unicode

2018-12-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: There is no code that prevents unicode.encode() from returning the result of arbitrary type. Seems all standard codecs return str, but you can not be sure about custom codecs. -- nosy: +serhiy.storchaka ___

[issue35544] unicode.encode docstring says return value can be unicode

2018-12-20 Thread STINNER Victor
Change by STINNER Victor : -- nosy: +lemburg ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue35544] unicode.encode docstring says return value can be unicode

2018-12-20 Thread radiocane
New submission from radiocane : In Python 2.7.15rc1 the docstring for unicode.encode starts with: "S.encode([encoding[,errors]]) -> string or unicode" But if this answer https://stackoverflow.com/a/449281/5397695 is correct, then unicode.encode will never return a unicode object. Am I right?