bpo-39573: Finish converting to new Py_IS_TYPE() macro (GH-18601) · python/cpython@dffe4c0 (original) (raw)

`@@ -2052,8 +2052,8 @@ unsafe_latin_compare(PyObject *v, PyObject *w, MergeState *ms)

`

2052

2052

`int res;

`

2053

2053

``

2054

2054

`/* Modified from Objects/unicodeobject.c:unicode_compare, assuming: */

`

2055

``

`-

assert(Py_TYPE(v) == Py_TYPE(w));

`

2056

``

`-

assert(Py_TYPE(v) == &PyUnicode_Type);

`

``

2055

`+

assert(Py_IS_TYPE(v, &PyUnicode_Type));

`

``

2056

`+

assert(Py_IS_TYPE(w, &PyUnicode_Type));

`

2057

2057

`assert(PyUnicode_KIND(v) == PyUnicode_KIND(w));

`

2058

2058

`assert(PyUnicode_KIND(v) == PyUnicode_1BYTE_KIND);

`

2059

2059

``

`@@ -2075,8 +2075,8 @@ unsafe_long_compare(PyObject *v, PyObject *w, MergeState *ms)

`

2075

2075

`PyLongObject *vl, *wl; sdigit v0, w0; int res;

`

2076

2076

``

2077

2077

`/* Modified from Objects/longobject.c:long_compare, assuming: */

`

2078

``

`-

assert(Py_TYPE(v) == Py_TYPE(w));

`

2079

``

`-

assert(Py_TYPE(v) == &PyLong_Type);

`

``

2078

`+

assert(Py_IS_TYPE(v, &PyLong_Type));

`

``

2079

`+

assert(Py_IS_TYPE(w, &PyLong_Type));

`

2080

2080

`assert(Py_ABS(Py_SIZE(v)) <= 1);

`

2081

2081

`assert(Py_ABS(Py_SIZE(w)) <= 1);

`

2082

2082

``

`@@ -2103,8 +2103,8 @@ unsafe_float_compare(PyObject *v, PyObject *w, MergeState *ms)

`

2103

2103

`int res;

`

2104

2104

``

2105

2105

`/* Modified from Objects/floatobject.c:float_richcompare, assuming: */

`

2106

``

`-

assert(Py_TYPE(v) == Py_TYPE(w));

`

2107

``

`-

assert(Py_TYPE(v) == &PyFloat_Type);

`

``

2106

`+

assert(Py_IS_TYPE(v, &PyFloat_Type));

`

``

2107

`+

assert(Py_IS_TYPE(w, &PyFloat_Type));

`

2108

2108

``

2109

2109

`res = PyFloat_AS_DOUBLE(v) < PyFloat_AS_DOUBLE(w);

`

2110

2110

`assert(res == PyObject_RichCompareBool(v, w, Py_LT));

`

`@@ -2125,8 +2125,8 @@ unsafe_tuple_compare(PyObject *v, PyObject *w, MergeState *ms)

`

2125

2125

`int k;

`

2126

2126

``

2127

2127

`/* Modified from Objects/tupleobject.c:tuplerichcompare, assuming: */

`

2128

``

`-

assert(Py_TYPE(v) == Py_TYPE(w));

`

2129

``

`-

assert(Py_TYPE(v) == &PyTuple_Type);

`

``

2128

`+

assert(Py_IS_TYPE(v, &PyTuple_Type));

`

``

2129

`+

assert(Py_IS_TYPE(w, &PyTuple_Type));

`

2130

2130

`assert(Py_SIZE(v) > 0);

`

2131

2131

`assert(Py_SIZE(w) > 0);

`

2132

2132

``

`@@ -2247,7 +2247,7 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)

`

2247

2247

` * set ms appropriately. */

`

2248

2248

`if (saved_ob_size > 1) {

`

2249

2249

`/* Assume the first element is representative of the whole list. */

`

2250

``

`-

int keys_are_in_tuples = (Py_TYPE(lo.keys[0]) == &PyTuple_Type &&

`

``

2250

`+

int keys_are_in_tuples = (Py_IS_TYPE(lo.keys[0], &PyTuple_Type) &&

`

2251

2251

`Py_SIZE(lo.keys[0]) > 0);

`

2252

2252

``

2253

2253

`PyTypeObject* key_type = (keys_are_in_tuples ?

`

`@@ -2262,7 +2262,7 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)

`

2262

2262

`for (i=0; i < saved_ob_size; i++) {

`

2263

2263

``

2264

2264

`if (keys_are_in_tuples &&

`

2265

``

`-

!(Py_TYPE(lo.keys[i]) == &PyTuple_Type && Py_SIZE(lo.keys[i]) != 0)) {

`

``

2265

`+

!(Py_IS_TYPE(lo.keys[i], &PyTuple_Type) && Py_SIZE(lo.keys[i]) != 0)) {

`

2266

2266

`keys_are_in_tuples = 0;

`

2267

2267

`keys_are_all_same_type = 0;

`

2268

2268

`break;

`

`@@ -2275,7 +2275,7 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)

`

2275

2275

`PyTuple_GET_ITEM(lo.keys[i], 0) :

`

2276

2276

`lo.keys[i]);

`

2277

2277

``

2278

``

`-

if (Py_TYPE(key) != key_type) {

`

``

2278

`+

if (!Py_IS_TYPE(key, key_type)) {

`

2279

2279

`keys_are_all_same_type = 0;

`

2280

2280

`/* If keys are in tuple we must loop over the whole list to make

`

2281

2281

` sure all items are tuples */

`