bpo-29865: Use PyXXX_GET_SIZE macros rather than Py_SIZE for concrete types. (#748)

diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index 59e9beb..4f6dddb 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -83,7 +83,7 @@
         return NULL;
     }
 
-    len = Py_SIZE(data);
+    len = PyBytes_GET_SIZE(data);
     if (len > buffer->len) {
         PyErr_Format(PyExc_ValueError,
                      "read() returned too much data: "
diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c
index 59b917d..f78b447 100644
--- a/Modules/_io/bytesio.c
+++ b/Modules/_io/bytesio.c
@@ -822,7 +822,7 @@
     /* We allow the state tuple to be longer than 3, because we may need
        someday to extend the object's state without breaking
        backward-compatibility. */
-    if (!PyTuple_Check(state) || Py_SIZE(state) < 3) {
+    if (!PyTuple_Check(state) || PyTuple_GET_SIZE(state) < 3) {
         PyErr_Format(PyExc_TypeError,
                      "%.200s.__setstate__ argument should be 3-tuple, got %.200s",
                      Py_TYPE(self)->tp_name, Py_TYPE(state)->tp_name);
diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c
index ee6ad47..b176457 100644
--- a/Modules/_io/iobase.c
+++ b/Modules/_io/iobase.c
@@ -518,7 +518,7 @@
     if (buffer == NULL)
         return NULL;
 
-    while (limit < 0 || Py_SIZE(buffer) < limit) {
+    while (limit < 0 || PyByteArray_GET_SIZE(buffer) < limit) {
         Py_ssize_t nreadahead = 1;
         PyObject *b;
 
diff --git a/Modules/_io/stringio.c b/Modules/_io/stringio.c
index a73171f..ef45032 100644
--- a/Modules/_io/stringio.c
+++ b/Modules/_io/stringio.c
@@ -877,7 +877,7 @@
     /* We allow the state tuple to be longer than 4, because we may need
        someday to extend the object's state without breaking
        backward-compatibility. */
-    if (!PyTuple_Check(state) || Py_SIZE(state) < 4) {
+    if (!PyTuple_Check(state) || PyTuple_GET_SIZE(state) < 4) {
         PyErr_Format(PyExc_TypeError,
                      "%.200s.__setstate__ argument should be 4-tuple, got %.200s",
                      Py_TYPE(self)->tp_name, Py_TYPE(state)->tp_name);
diff --git a/Modules/_json.c b/Modules/_json.c
index f4000f8..28fdc79 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -1654,7 +1654,7 @@
     idx = 0;
     while ((item = PyIter_Next(it)) != NULL) {
         PyObject *encoded, *key, *value;
-        if (!PyTuple_Check(item) || Py_SIZE(item) != 2) {
+        if (!PyTuple_Check(item) || PyTuple_GET_SIZE(item) != 2) {
             PyErr_SetString(PyExc_ValueError, "items must return 2-tuples");
             goto bail;
         }
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index e65b88e..a6f3abe 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -3559,10 +3559,10 @@
         PyObject *args;
         PyObject *kwargs;
 
-        if (Py_SIZE(argtup) != 3) {
+        if (PyTuple_GET_SIZE(argtup) != 3) {
             PyErr_Format(st->PicklingError,
                          "length of the NEWOBJ_EX argument tuple must be "
-                         "exactly 3, not %zd", Py_SIZE(argtup));
+                         "exactly 3, not %zd", PyTuple_GET_SIZE(argtup));
             return -1;
         }
 
@@ -3602,7 +3602,7 @@
             Py_ssize_t i;
             _Py_IDENTIFIER(__new__);
 
-            newargs = PyTuple_New(Py_SIZE(args) + 2);
+            newargs = PyTuple_New(PyTuple_GET_SIZE(args) + 2);
             if (newargs == NULL)
                 return -1;
 
@@ -3614,7 +3614,7 @@
             PyTuple_SET_ITEM(newargs, 0, cls_new);
             Py_INCREF(cls);
             PyTuple_SET_ITEM(newargs, 1, cls);
-            for (i = 0; i < Py_SIZE(args); i++) {
+            for (i = 0; i < PyTuple_GET_SIZE(args); i++) {
                 PyObject *item = PyTuple_GET_ITEM(args, i);
                 Py_INCREF(item);
                 PyTuple_SET_ITEM(newargs, i + 2, item);
@@ -3649,7 +3649,7 @@
         int p;
 
         /* Sanity checks. */
-        if (Py_SIZE(argtup) < 1) {
+        if (PyTuple_GET_SIZE(argtup) < 1) {
             PyErr_SetString(st->PicklingError, "__newobj__ arglist is empty");
             return -1;
         }
@@ -3702,7 +3702,7 @@
         if (save(self, cls, 0) < 0)
             return -1;
 
-        newargtup = PyTuple_GetSlice(argtup, 1, Py_SIZE(argtup));
+        newargtup = PyTuple_GetSlice(argtup, 1, PyTuple_GET_SIZE(argtup));
         if (newargtup == NULL)
             return -1;
 
@@ -4431,7 +4431,7 @@
             Py_ssize_t memo_id;
             PyObject *memo_obj;
 
-            if (!PyTuple_Check(value) || Py_SIZE(value) != 2) {
+            if (!PyTuple_Check(value) || PyTuple_GET_SIZE(value) != 2) {
                 PyErr_SetString(PyExc_TypeError,
                                 "'memo' values must be 2-item tuples");
                 goto error;
@@ -5168,7 +5168,7 @@
        Pdata_poptuple which packs objects from the top of the stack
        into a newly created tuple. */
     assert(PyTuple_Check(args));
-    if (Py_SIZE(args) > 0 || !PyType_Check(cls) ||
+    if (PyTuple_GET_SIZE(args) > 0 || !PyType_Check(cls) ||
         _PyObject_HasAttrId(cls, &PyId___getinitargs__)) {
         result = PyObject_CallObject(cls, args);
     }
@@ -6048,7 +6048,7 @@
     /* A default __setstate__.  First see whether state embeds a
      * slot state dict too (a proto 2 addition).
      */
-    if (PyTuple_Check(state) && Py_SIZE(state) == 2) {
+    if (PyTuple_Check(state) && PyTuple_GET_SIZE(state) == 2) {
         PyObject *tmp = state;
 
         state = PyTuple_GET_ITEM(tmp, 0);
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index 7cbee2b..f867252 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -942,11 +942,11 @@
             return NULL;
         Py_CLEAR(lz->it);
     }
-    if (Py_SIZE(lz->saved) == 0)
+    if (PyList_GET_SIZE(lz->saved) == 0)
         return NULL;
     item = PyList_GET_ITEM(lz->saved, lz->index);
     lz->index++;
-    if (lz->index >= Py_SIZE(lz->saved))
+    if (lz->index >= PyList_GET_SIZE(lz->saved))
         lz->index = 0;
     Py_INCREF(item);
     return item;