[issue26421] string_richcompare invalid check Py_NotImplemented

2016-02-26 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: PyDict_GetItem and lookdict_string use PyString_CheckExact for fast path. String subclasses are proceeded in general way. PyObject_GetAttr and string_richcompare use PyString_Check because they work with string and string subclasses. Py_TPFLAGS_STRING_SUBCLA

[issue26421] string_richcompare invalid check Py_NotImplemented

2016-02-26 Thread yuriy_levchenko
yuriy_levchenko added the comment: because, PyObject_GetAttr(PyObject *v, PyObject *name) have this code if (!PyString_Check(name)) { and PyDict_GetItem(PyObject *op, PyObject *key) have this code if (!PyString_CheckExact(key) || (hash = ((PyStringObject *) key)->ob_shash) ==

[issue26421] string_richcompare invalid check Py_NotImplemented

2016-02-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: If your type is not PyStringObject, why it has the Py_TPFLAGS_STRING_SUBCLASS flag set? -- nosy: +serhiy.storchaka ___ Python tracker ___ ___

[issue26421] string_richcompare invalid check Py_NotImplemented

2016-02-23 Thread yuriy_levchenko
New submission from yuriy_levchenko: i have object with flag Py_TPFLAGS_STRING_SUBCLASS stringobject.c (line 1192) in function string_richcompare we have check string PyString_Check but, #define PyString_Check(op) \ PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_STRING_SUBCLASS)