diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-03-21 06:53:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-21 06:53:25 (GMT) |
commit | fff9a31a91283c39c363af219e595eab7d4da6f7 (patch) | |
tree | 0dfdec9e4e3e7caec6804bcc1fef1f2c19b9e532 /Objects | |
parent | c61ac1642d19f54c7b755098230967ad2e603180 (diff) | |
download | cpython-fff9a31a91283c39c363af219e595eab7d4da6f7.zip cpython-fff9a31a91283c39c363af219e595eab7d4da6f7.tar.gz cpython-fff9a31a91283c39c363af219e595eab7d4da6f7.tar.bz2 |
bpo-29865: Use PyXXX_GET_SIZE macros rather than Py_SIZE for concrete types. (#748)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/call.c | 14 | ||||
-rw-r--r-- | Objects/descrobject.c | 2 | ||||
-rw-r--r-- | Objects/memoryobject.c | 2 | ||||
-rw-r--r-- | Objects/typeobject.c | 12 | ||||
-rw-r--r-- | Objects/unicodeobject.c | 3 |
5 files changed, 18 insertions, 15 deletions
diff --git a/Objects/call.c b/Objects/call.c index dd022ec..7890c13 100644 --- a/Objects/call.c +++ b/Objects/call.c @@ -321,11 +321,12 @@ _PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, return function_code_fastcall(co, args, nargs, globals); } else if (nargs == 0 && argdefs != NULL - && co->co_argcount == Py_SIZE(argdefs)) { + && co->co_argcount == PyTuple_GET_SIZE(argdefs)) { /* function called with no arguments, but all parameters have a default value: use default values as arguments .*/ args = &PyTuple_GET_ITEM(argdefs, 0); - return function_code_fastcall(co, args, Py_SIZE(argdefs), globals); + return function_code_fastcall(co, args, PyTuple_GET_SIZE(argdefs), + globals); } } @@ -364,7 +365,7 @@ _PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, if (argdefs != NULL) { d = &PyTuple_GET_ITEM(argdefs, 0); - nd = Py_SIZE(argdefs); + nd = PyTuple_GET_SIZE(argdefs); } else { d = NULL; @@ -406,11 +407,12 @@ _PyFunction_FastCallKeywords(PyObject *func, PyObject **stack, return function_code_fastcall(co, stack, nargs, globals); } else if (nargs == 0 && argdefs != NULL - && co->co_argcount == Py_SIZE(argdefs)) { + && co->co_argcount == PyTuple_GET_SIZE(argdefs)) { /* function called with no arguments, but all parameters have a default value: use default values as arguments .*/ stack = &PyTuple_GET_ITEM(argdefs, 0); - return function_code_fastcall(co, stack, Py_SIZE(argdefs), globals); + return function_code_fastcall(co, stack, PyTuple_GET_SIZE(argdefs), + globals); } } @@ -421,7 +423,7 @@ _PyFunction_FastCallKeywords(PyObject *func, PyObject **stack, if (argdefs != NULL) { d = &PyTuple_GET_ITEM(argdefs, 0); - nd = Py_SIZE(argdefs); + nd = PyTuple_GET_SIZE(argdefs); } else { d = NULL; diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 8677cdd..1d11605 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1385,7 +1385,7 @@ property_descr_get(PyObject *self, PyObject *obj, PyObject *type) PyTuple_SET_ITEM(args, 0, obj); ret = PyObject_Call(gs->prop_get, args, NULL); if (cached_args == NULL && Py_REFCNT(args) == 1) { - assert(Py_SIZE(args) == 1); + assert(PyTuple_GET_SIZE(args) == 1); assert(PyTuple_GET_ITEM(args, 0) == obj); cached_args = args; Py_DECREF(obj); diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index b1798a2..8a23163 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -2143,7 +2143,7 @@ memory_hex(PyMemoryViewObject *self, PyObject *dummy) if (bytes == NULL) return NULL; - ret = _Py_strhex(PyBytes_AS_STRING(bytes), Py_SIZE(bytes)); + ret = _Py_strhex(PyBytes_AS_STRING(bytes), PyBytes_GET_SIZE(bytes)); Py_DECREF(bytes); return ret; diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 3e1e8d7..64a72d2 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4022,7 +4022,7 @@ _PyObject_GetState(PyObject *obj, int required) if (obj->ob_type->tp_weaklistoffset) basicsize += sizeof(PyObject *); if (slotnames != Py_None) - basicsize += sizeof(PyObject *) * Py_SIZE(slotnames); + basicsize += sizeof(PyObject *) * PyList_GET_SIZE(slotnames); if (obj->ob_type->tp_basicsize > basicsize) { Py_DECREF(slotnames); Py_DECREF(state); @@ -4033,7 +4033,7 @@ _PyObject_GetState(PyObject *obj, int required) } } - if (slotnames != Py_None && Py_SIZE(slotnames) > 0) { + if (slotnames != Py_None && PyList_GET_SIZE(slotnames) > 0) { PyObject *slots; Py_ssize_t slotnames_size, i; @@ -4044,7 +4044,7 @@ _PyObject_GetState(PyObject *obj, int required) return NULL; } - slotnames_size = Py_SIZE(slotnames); + slotnames_size = PyList_GET_SIZE(slotnames); for (i = 0; i < slotnames_size; i++) { PyObject *name, *value; @@ -4070,7 +4070,7 @@ _PyObject_GetState(PyObject *obj, int required) /* The list is stored on the class so it may mutate while we iterate over it */ - if (slotnames_size != Py_SIZE(slotnames)) { + if (slotnames_size != PyList_GET_SIZE(slotnames)) { PyErr_Format(PyExc_RuntimeError, "__slotsname__ changed size during iteration"); goto error; @@ -4142,10 +4142,10 @@ _PyObject_GetNewArguments(PyObject *obj, PyObject **args, PyObject **kwargs) Py_DECREF(newargs); return -1; } - if (Py_SIZE(newargs) != 2) { + if (PyTuple_GET_SIZE(newargs) != 2) { PyErr_Format(PyExc_ValueError, "__getnewargs_ex__ should return a tuple of " - "length 2, not %zd", Py_SIZE(newargs)); + "length 2, not %zd", PyTuple_GET_SIZE(newargs)); Py_DECREF(newargs); return -1; } diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 1a696cc..d3a7f54 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -3633,7 +3633,8 @@ PyUnicode_AsEncodedString(PyObject *unicode, return NULL; } - b = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(v), Py_SIZE(v)); + b = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(v), + PyByteArray_GET_SIZE(v)); Py_DECREF(v); return b; } |