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 yuriy_levchenko
Recipients serhiy.storchaka, yuriy_levchenko
Date 2016-02-26.12:03:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1456488228.54.0.0179672395776.issue26421@psf.upfronthosting.co.za>
In-reply-to
Content
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) == -1)
    {
        hash = PyObject_Hash(key);

next

lookdict_string(PyDictObject *mp, PyObject *key, register long hash)

    if (!PyString_CheckExact(key)) {
#ifdef SHOW_CONVERSION_COUNTS
        ++converted;
#endif
        mp->ma_lookup = lookdict;
        return lookdict(mp, key, hash);
    }

next

PyObject_RichCompare(PyObject *v, PyObject *w, int op)

and 

try_rich_compare(PyObject *v, PyObject *w, int op)

we have this code

    if ((f = RICHCOMPARE(v->ob_type)) != NULL) {
        res = (*f)(v, w, op);
        if (res != Py_NotImplemented)
            return res;
        Py_DECREF(res);
    }
    if ((f = RICHCOMPARE(w->ob_type)) != NULL) {
        return (*f)(w, v, _Py_SwappedOp[op]);
    }

v - PyStringObject
w - MyType

MyType have Py_TPFLAGS_HAVE_RICHCOMPARE and correct test with PyStringObject

but string_richcompare incorrect test type for object, and this code

a->ob_sval 

may cause "access violation" and crach!

if i replace PyString_Check on PyString_CheckExact, all work fine and correct!
History
Date User Action Args
2016-02-26 12:03:48yuriy_levchenkosetrecipients: + yuriy_levchenko, serhiy.storchaka
2016-02-26 12:03:48yuriy_levchenkosetmessageid: <1456488228.54.0.0179672395776.issue26421@psf.upfronthosting.co.za>
2016-02-26 12:03:48yuriy_levchenkolinkissue26421 messages
2016-02-26 12:03:47yuriy_levchenkocreate