summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-02-07 10:18:33 (GMT)
committerGitHub <noreply@github.com>2020-02-07 10:18:33 (GMT)
commitc65b320a95784d2b2133926921d67ac439259e9f (patch)
tree9d48fe11d9de8dc3397a992d333b74873ba71128 /Objects/object.c
parentbec4186c67345f1e6cd3f8a531bc228f14d7ed7b (diff)
downloadcpython-c65b320a95784d2b2133926921d67ac439259e9f.zip
cpython-c65b320a95784d2b2133926921d67ac439259e9f.tar.gz
cpython-c65b320a95784d2b2133926921d67ac439259e9f.tar.bz2
bpo-39573: Use Py_TYPE() macro in object.c (GH-18398)
Replace direct acccess to PyVarObject.ob_size with usage of the Py_SIZE() macro.
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 503fb86..ff6c497 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1041,13 +1041,11 @@ _PyObject_GetDictPtr(PyObject *obj)
if (dictoffset == 0)
return NULL;
if (dictoffset < 0) {
- Py_ssize_t tsize;
- size_t size;
-
- tsize = ((PyVarObject *)obj)->ob_size;
- if (tsize < 0)
+ Py_ssize_t tsize = Py_SIZE(obj);
+ if (tsize < 0) {
tsize = -tsize;
- size = _PyObject_VAR_SIZE(tp, tsize);
+ }
+ size_t size = _PyObject_VAR_SIZE(tp, tsize);
dictoffset += (long)size;
_PyObject_ASSERT(obj, dictoffset > 0);
@@ -1219,13 +1217,11 @@ _PyObject_GenericGetAttrWithDict(PyObject *obj, PyObject *name,
dictoffset = tp->tp_dictoffset;
if (dictoffset != 0) {
if (dictoffset < 0) {
- Py_ssize_t tsize;
- size_t size;
-
- tsize = ((PyVarObject *)obj)->ob_size;
- if (tsize < 0)
+ Py_ssize_t tsize = Py_SIZE(obj);
+ if (tsize < 0) {
tsize = -tsize;
- size = _PyObject_VAR_SIZE(tp, tsize);
+ }
+ size_t size = _PyObject_VAR_SIZE(tp, tsize);
_PyObject_ASSERT(obj, size <= PY_SSIZE_T_MAX);
dictoffset += (Py_ssize_t)size;