gh-99845: Change _PyDict_KeysSize() return type to size_t (#99848)

* Change _PyDict_KeysSize() and shared_keys_usable_size() return type
  from signed (Py_ssize_t) to unsigned (size_t) type.
* new_values() argument type is now unsigned (size_t).
* init_inline_values() now uses size_t rather than int for the 'i'
  iterator variable.
* type.__sizeof__() implementation now uses unsigned (size_t) type.
This commit is contained in:
Victor Stinner 2022-11-29 12:12:17 +01:00 committed by GitHub
parent 4cfc1b8568
commit 4246fe977d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 35 deletions

View file

@ -4680,16 +4680,17 @@ static PyObject *
type___sizeof___impl(PyTypeObject *self)
/*[clinic end generated code: output=766f4f16cd3b1854 input=99398f24b9cf45d6]*/
{
Py_ssize_t size;
size_t size;
if (self->tp_flags & Py_TPFLAGS_HEAPTYPE) {
PyHeapTypeObject* et = (PyHeapTypeObject*)self;
size = sizeof(PyHeapTypeObject);
if (et->ht_cached_keys)
size += _PyDict_KeysSize(et->ht_cached_keys);
}
else
else {
size = sizeof(PyTypeObject);
return PyLong_FromSsize_t(size);
}
return PyLong_FromSize_t(size);
}
static PyMethodDef type_methods[] = {