New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ms.key_compare is not initialized in all paths of list_sort_impl() #78170
Comments
Relevant code (Objects/listobject.c lines 2268 -- 2286 as of commit e76ac9d): /* Choose the best compare, given what we now know about the keys. */
if (keys_are_all_same_type) {
if (key_type == &PyUnicode_Type && strings_are_latin) {
ms.key_compare = unsafe_latin_compare;
}
else if (key_type == &PyLong_Type && ints_are_bounded) {
ms.key_compare = unsafe_long_compare;
}
else if (key_type == &PyFloat_Type) {
ms.key_compare = unsafe_float_compare;
}
else if ((ms.key_richcompare = key_type->tp_richcompare) != NULL) {
ms.key_compare = unsafe_object_compare;
}
}
else {
ms.key_compare = safe_object_compare;
} Clearly, ms.key_compare is not assigned here if keys_are_all_same_type is true but key_type->tp_richcompare is NULL. I don't know how to obtain an object with ob_type->tp_richcompare being NULL, though. |
Do you want to submit a patch? |
Serhiy, do you want to take this one? |
You can always fall back on safe_object_compare. So unless there's an |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: