Issue #22207: Fix "comparison between signed and unsigned integers" warning in
test checking for integer overflow on Py_ssize_t type: cast explicitly to
size_t.
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index 1b21300..ac25998 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -699,7 +699,7 @@
         u = PyUnicode_AsUnicodeAndSize(obj, &len);
         if (u == NULL)
             return NULL;
-        if (len > PY_SSIZE_T_MAX / sizeof(Py_UNICODE))
+        if ((size_t)len > (size_t)PY_SSIZE_T_MAX / sizeof(Py_UNICODE))
             return PyErr_NoMemory();
         size = len * sizeof(Py_UNICODE);
         return codec_tuple(PyBytes_FromStringAndSize((const char*)u, size),
diff --git a/Modules/_lzmamodule.c b/Modules/_lzmamodule.c
index c43676a..dfb95fa 100644
--- a/Modules/_lzmamodule.c
+++ b/Modules/_lzmamodule.c
@@ -533,7 +533,7 @@
             c->lzs.avail_out = PyBytes_GET_SIZE(result) - data_size;
         }
     }
-    if (data_size != PyBytes_GET_SIZE(result))
+    if (data_size != (size_t)PyBytes_GET_SIZE(result))
         if (_PyBytes_Resize(&result, data_size) == -1)
             goto error;
     return result;
@@ -931,7 +931,7 @@
             d->lzs.avail_out = PyBytes_GET_SIZE(result) - data_size;
         }
     }
-    if (data_size != PyBytes_GET_SIZE(result))
+    if (data_size != (size_t)PyBytes_GET_SIZE(result))
         if (_PyBytes_Resize(&result, data_size) == -1)
             goto error;
     return result;
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 1c15190..ba9ba99 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -2052,7 +2052,8 @@
 {
     PyObject *repr;
     char *p;
-    Py_ssize_t i, size, expandsize;
+    Py_ssize_t i, size;
+    size_t expandsize;
     void *data;
     unsigned int kind;
 
@@ -2067,7 +2068,7 @@
     else
         expandsize = 6;
 
-    if (size > PY_SSIZE_T_MAX / expandsize)
+    if ((size_t)size > (size_t)PY_SSIZE_T_MAX / expandsize)
         return PyErr_NoMemory();
     repr = PyBytes_FromStringAndSize(NULL, expandsize * size);
     if (repr == NULL)
diff --git a/Modules/fcntlmodule.c b/Modules/fcntlmodule.c
index cf0ac19..56e4021 100644
--- a/Modules/fcntlmodule.c
+++ b/Modules/fcntlmodule.c
@@ -42,7 +42,7 @@
 
     if (PyArg_ParseTuple(args, "O&is#:fcntl",
                          conv_descriptor, &fd, &code, &str, &len)) {
-        if (len > sizeof buf) {
+        if ((size_t)len > sizeof buf) {
             PyErr_SetString(PyExc_ValueError,
                             "fcntl string arg too long");
             return NULL;
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index 7f525ea..bce3799 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -1010,7 +1010,7 @@
     Py_ssize_t m = *m_ptr;
 
     m += m;  /* double */
-    if (n < m && m < (PY_SSIZE_T_MAX / sizeof(double))) {
+    if (n < m && (size_t)m < ((size_t)PY_SSIZE_T_MAX / sizeof(double))) {
         double *p = *p_ptr;
         if (p == ps) {
             v = PyMem_Malloc(sizeof(double) * m);
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index c5af253..f0c26c3 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -81,6 +81,7 @@
 {
     PyBytesObject *op;
     assert(size >= 0);
+
     if (size == 0 && (op = nullstring) != NULL) {
 #ifdef COUNT_ALLOCS
         null_strings++;
@@ -89,7 +90,7 @@
         return (PyObject *)op;
     }
 
-    if (size > PY_SSIZE_T_MAX - PyBytesObject_SIZE) {
+    if ((size_t)size > (size_t)PY_SSIZE_T_MAX - PyBytesObject_SIZE) {
         PyErr_SetString(PyExc_OverflowError,
                         "byte string is too large");
         return NULL;
@@ -1755,7 +1756,7 @@
 bytes.translate
 
     self: self(type="PyBytesObject *")
-    table: object   
+    table: object
         Translation table, which must be a bytes object of length 256.
     [
     deletechars: object
@@ -3328,7 +3329,7 @@
         /* Only one reference, so we can resize in place */
         Py_ssize_t oldsize;
         Py_buffer wb;
-        
+
         wb.len = -1;
         if (_getbuffer(w, &wb) < 0) {
             PyErr_Format(PyExc_TypeError, "can't concat %.100s to %.100s",
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index 753097b..e45462b 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -97,7 +97,7 @@
 #endif
     {
         /* Check for overflow */
-        if (size > (PY_SSIZE_T_MAX - sizeof(PyTupleObject) -
+        if ((size_t)size > ((size_t)PY_SSIZE_T_MAX - sizeof(PyTupleObject) -
                     sizeof(PyObject *)) / sizeof(PyObject *)) {
             return PyErr_NoMemory();
         }
diff --git a/Python/asdl.c b/Python/asdl.c
index 74fa941..df387b2 100644
--- a/Python/asdl.c
+++ b/Python/asdl.c
@@ -5,21 +5,21 @@
 _Py_asdl_seq_new(Py_ssize_t size, PyArena *arena)
 {
     asdl_seq *seq = NULL;
-    size_t n = (size ? (sizeof(void *) * (size - 1)) : 0);
+    size_t n;
 
     /* check size is sane */
-    if (size < 0 || size == INT_MIN ||
-        (size && ((size - 1) > (PY_SIZE_MAX / sizeof(void *))))) {
+    if (size < 0 ||
+        (size && (((size_t)size - 1) > (PY_SIZE_MAX / sizeof(void *))))) {
         PyErr_NoMemory();
         return NULL;
     }
+    n = (size ? (sizeof(void *) * (size - 1)) : 0);
 
     /* check if size can be added safely */
     if (n > PY_SIZE_MAX - sizeof(asdl_seq)) {
         PyErr_NoMemory();
         return NULL;
     }
-
     n += sizeof(asdl_seq);
 
     seq = (asdl_seq *)PyArena_Malloc(arena, n);
@@ -36,21 +36,21 @@
 _Py_asdl_int_seq_new(Py_ssize_t size, PyArena *arena)
 {
     asdl_int_seq *seq = NULL;
-    size_t n = (size ? (sizeof(void *) * (size - 1)) : 0);
+    size_t n;
 
     /* check size is sane */
-    if (size < 0 || size == INT_MIN ||
-        (size && ((size - 1) > (PY_SIZE_MAX / sizeof(void *))))) {
+    if (size < 0 ||
+        (size && (((size_t)size - 1) > (PY_SIZE_MAX / sizeof(void *))))) {
             PyErr_NoMemory();
             return NULL;
     }
+    n = (size ? (sizeof(void *) * (size - 1)) : 0);
 
     /* check if size can be added safely */
     if (n > PY_SIZE_MAX - sizeof(asdl_seq)) {
         PyErr_NoMemory();
         return NULL;
     }
-
     n += sizeof(asdl_seq);
 
     seq = (asdl_int_seq *)PyArena_Malloc(arena, n);