@@ -2959,10 +2959,10 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, PyObject *keylist,
29592959 Py_ssize_t i ;
29602960 PyObject * * keys ;
29612961 // keylist vars
2962- PyListObject * self_kl ;
2963- Py_ssize_t keylist_ob_size , keylist_allocated ;
2964- PyObject * * keylist_ob_item ;
2965- int keylist_frozen = 0 ;
2962+ PyListObject * keylist_lob ;
2963+ Py_ssize_t keylist_ob_size = -1 ;
2964+ Py_ssize_t keylist_allocated = -1 ;
2965+ PyObject * * keylist_ob_item = NULL ;
29662966
29672967 assert (self != NULL );
29682968 assert (PyList_Check (self ));
@@ -3027,9 +3027,8 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, PyObject *keylist,
30273027 goto keyfunc_fail ;
30283028 }
30293029
3030- self_kl = ((PyListObject * ) keylist );
3031- DISABLE_LIST (self_kl , keylist_ob_size , keylist_ob_item , keylist_allocated );
3032- keylist_frozen = 1 ;
3030+ keylist_lob = ((PyListObject * ) keylist );
3031+ DISABLE_LIST (keylist_lob , keylist_ob_size , keylist_ob_item , keylist_allocated );
30333032 if (saved_ob_size != keylist_ob_size ) {
30343033 PyErr_SetString (PyExc_ValueError ,
30353034 "Lengths of input list and keylist differ." );
@@ -3219,8 +3218,8 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, PyObject *keylist,
32193218 merge_freemem (& ms );
32203219
32213220keylist_fail :
3222- if (keylist_frozen ) {
3223- if (self_kl -> allocated != -1 && result != NULL ) {
3221+ if (keylist_ob_size != -1 ) {
3222+ if (keylist_lob -> allocated != -1 && result != NULL ) {
32243223 /* The user mucked with the keylist during the sort,
32253224 * and we don't already have another error to report.
32263225 */
@@ -3231,7 +3230,7 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, PyObject *keylist,
32313230 if (reverse && keylist_ob_size > 1 )
32323231 reverse_slice (keylist_ob_item , keylist_ob_item + keylist_ob_size );
32333232
3234- REENABLE_LIST (self_kl , keylist_ob_size , keylist_ob_item , keylist_allocated );
3233+ REENABLE_LIST (keylist_lob , keylist_ob_size , keylist_ob_item , keylist_allocated );
32353234 final_ob_item = NULL ;
32363235 }
32373236
0 commit comments