Arno-Can Uestuensoez <acue.opensou...@gmail.com> 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 Desktop]$ python -bb Python 3.6.2 (default, Jul 29 2017, 14:24:56) [GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> >>> str(b"abc") Traceback (most recent call last): File "<stdin>", line 1, in <module> BytesWarning: str() on a bytes instance >>> >>> >>> str(b"abc", "utf-8") 'abc' >>> >>> type(str(b"abc",'utf-8')) <class 'str'> >>> Is there a common approach to force the use of the str()-constructor instead of the str()-built-in function and/or the __str__()-method? This would make the shared code of Python2/Python3 much easier, at least for unicode()->str(). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32078> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com