Issue 1166195: Using size_t where appropriate (original) (raw)

This patch is (a first draft of) an attempt to make Python properly use size_t where necessary. This work is triggered by compilation on Win64 (where the compiler warns about potential truncation errors a lot). The rationale for the patch is that size_t might be larger than int, in particular on 64-bit platforms, and that the size of a memory chunk cannot reliably be measured with an int.

It turns out that using size_t is not enough, since values can sometimes also be negative. For these cases, a "signed" size_t is used, which is called Py_ssize_t and is a define for ssize_t if the compiler supports the latter.

The guideline for converting int to size_t used in this patch is this:

This version is work in progress, and needs review. I hope to work on it during the sprints at PyConDC.