Skip to content

Commit a7746e0

Browse files
committed
Correctly round sizeof() for code object.
1 parent 704d217 commit a7746e0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Objects/codeobject.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,8 +1382,10 @@ code_sizeof(PyCodeObject *co, PyObject *Py_UNUSED(args))
13821382
}
13831383

13841384
if (co->co_quickened != NULL) {
1385-
res += co->co_quickened[0].entry.zero.cache_count * sizeof(SpecializedCacheEntry);
1386-
res += PyBytes_GET_SIZE(co->co_code);
1385+
Py_ssize_t count = co->co_quickened[0].entry.zero.cache_count;
1386+
count += (PyBytes_GET_SIZE(co->co_code)+sizeof(SpecializedCacheEntry)-1)/
1387+
sizeof(SpecializedCacheEntry);
1388+
res += count * sizeof(SpecializedCacheEntry);
13871389
}
13881390

13891391
return PyLong_FromSsize_t(res);

0 commit comments

Comments
 (0)