Message323329
> 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
False
So Eric is right, there's a small discrepancy between Python and C version. |
|
Date |
User |
Action |
Args |
2018-08-09 14:55:28 | yselivanov | set | recipients:
+ yselivanov, asvetlov, alex.gronholm, eric.snow |
2018-08-09 14:55:28 | yselivanov | set | messageid: <1533826528.24.0.56676864532.issue34270@psf.upfronthosting.co.za> |
2018-08-09 14:55:28 | yselivanov | link | issue34270 messages |
2018-08-09 14:55:28 | yselivanov | create | |
|