https://github.com/python/cpython/commit/24520d7aea8e6f105d496365f905f36dd676f9de
commit: 24520d7aea8e6f105d496365f905f36dd676f9de
branch: 3.14
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-11-03T18:31:18+01:00
summary:
[3.14] Fix a compiler warning in py_list_resize() (#161190)
Fix a compiler warning in py_list_resize()
Fix a compiler warning when Python is built with the GIL (default)
and without C assertions (in release mode). Fix the warning:
Objects/listobject.c: In function 'py_list_resize':
Objects/listobject.c:140:16: warning: unused variable 'allocated'
[-Wunused-variable]
140 | Py_ssize_t allocated = self->allocated;
files:
M Objects/listobject.c
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 063830c68688990..6de6b864df45559 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -137,7 +137,6 @@ static int
py_list_resize(PyListObject *self, Py_ssize_t newsize)
{
size_t new_allocated, target_bytes;
- Py_ssize_t allocated = self->allocated;
/* This over-allocates proportional to the list size, making room
* for additional growth. The over-allocation is mild, but is
@@ -159,11 +158,12 @@ py_list_resize(PyListObject *self, Py_ssize_t newsize)
if (newsize == 0)
new_allocated = 0;
- assert(newsize > allocated || new_allocated < (size_t)allocated);
+ assert(newsize > self->allocated || new_allocated <
(size_t)self->allocated);
ensure_shared_on_resize(self);
#ifdef Py_GIL_DISABLED
+ Py_ssize_t allocated = self->allocated;
_PyListArray *array = list_allocate_array(new_allocated);
if (array == NULL) {
PyErr_NoMemory();
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]