[issue32078] string result of str(bytes()) in Python3

2017-11-20 Thread STINNER Victor
STINNER Victor added the comment: I'm sorry but the bug tracker is not the right place to ask such question. There are plenty of resources on the Internet explaining how to write code compatible with Python 2 and Python 3. -- ___ Python tracker

[issue32078] string result of str(bytes()) in Python3

2017-11-20 Thread Arno-Can Uestuensoez
Arno-Can Uestuensoez added the comment: I got your point, missed it before, sorry. So just for completeness. My issue was basically about the ambiguity of the str()-constructor and the str()-built-in-function. Therefore the len/type prints. It works with parameters: (3.6.2) [acue@lap001 Deskt

[issue32078] string result of str(bytes()) in Python3

2017-11-20 Thread STINNER Victor
STINNER Victor added the comment: Calling str(bytes) is wrong in Python 3: $ python3 -bb Python 3.6.2 (default, Oct 2 2017, 16:51:32) >>> str(b'abc') BytesWarning: str() on a bytes instance Just don't do that :-) Use repr(bytes) if you want the b'...' format: >>> repr(b'abc') "b'abc'" ---

[issue32078] string result of str(bytes()) in Python3

2017-11-19 Thread Arno-Can Uestuensoez
Arno-Can Uestuensoez added the comment: Sorry for the typo. -- Added file: https://bugs.python.org/file47276/howto_bytes_005typo.py ___ Python tracker ___ _

[issue32078] string result of str(bytes()) in Python3

2017-11-19 Thread Arno-Can Uestuensoez
Arno-Can Uestuensoez added the comment: Hello, the following reduced example probably shows the issue a little better. I have currently not yet the 3.7+ environment, but guess the same behavior. Regards Arno -- versions: +Python 3.7, Python 3.8 Added file: https://bugs.python.org/fil

[issue32078] string result of str(bytes()) in Python3

2017-11-19 Thread Arno-Can Uestuensoez
New submission from Arno-Can Uestuensoez : Hello, I am currently writing some dual-version libraries and have to deal with str/unicode. The attached code example contains the str/unicode handling. The Python3.6.2 release behaves as I did not expected for all of the following the conversions: