Skip to content

Commit 9537edd

Browse files
committed
Fix tests for PyPy2
1 parent 10ed348 commit 9537edd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tests/test_pythoncapi_compat_cext.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,12 +879,17 @@ test_vectorcall_args_kwnames(PyObject *func_varargs)
879879
Py_ssize_t pos = 0;
880880
PyObject *key, *value;
881881
while (PyDict_Next(kwargs, &pos, &key, &value)) {
882+
#ifdef PYTHON3
882883
assert(PyUnicode_Check(key));
883-
if (PyUnicode_Compare(key, key1) == 0) {
884+
#else
885+
// CPython 2.7 creates PyUnicode keys, PyPy2 creates PyString keys
886+
assert(PyString_Check(key) || PyUnicode_Check(key));
887+
#endif
888+
if (PyObject_RichCompareBool(key, key1, Py_EQ)) {
884889
check_int(value, 4);
885890
}
886891
else {
887-
assert(PyUnicode_Compare(key, key2) == 0);
892+
assert(PyObject_RichCompareBool(key, key2, Py_EQ));
888893
check_int(value, 5);
889894
}
890895
}

0 commit comments

Comments
 (0)