This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author acue
Recipients acue, ezio.melotti, vstinner
Date 2017-11-21.02:54:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1511232843.51.0.213398074469.issue32078@psf.upfronthosting.co.za>
In-reply-to
Content
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().
History
Date User Action Args
2017-11-21 02:54:03acuesetrecipients: + acue, vstinner, ezio.melotti
2017-11-21 02:54:03acuesetmessageid: <1511232843.51.0.213398074469.issue32078@psf.upfronthosting.co.za>
2017-11-21 02:54:03acuelinkissue32078 messages
2017-11-21 02:54:02acuecreate