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 yselivanov
Recipients alex.gronholm, asvetlov, eric.snow, yselivanov
Date 2018-08-09.14:55:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> I also couldn't figure out yet why PyUnicode_Check() was necessary in the first place. Doesn't PyObject_Str() just increment the refcount if the argument is already a string?

`str()` returns its argument if it's exactly a `builtins.str` instance.  If it's a subclass of str, it will construct a `builtins.str` out of it.

>>> class mystr(str):
...     pass
>>> a = mystr('aaa')
>>> str(a) is a

So Eric is right, there's a small discrepancy between Python and C version.
Date User Action Args
2018-08-09 14:55:28yselivanovsetrecipients: + yselivanov, asvetlov, alex.gronholm, eric.snow
2018-08-09 14:55:28yselivanovsetmessageid: <>
2018-08-09 14:55:28yselivanovlinkissue34270 messages
2018-08-09 14:55:28yselivanovcreate