port: advance VC6 typeobject frontier and preserve regression coverage
This commit is contained in:
@@ -51,3 +51,35 @@ text = check("PyObject_Repr", (
|
||||
), "PyObject_Repr must hoist tstate while preserving signal-check order")
|
||||
assert "PyThreadState *tstate =" not in text
|
||||
print("object PyObject_Repr C89 local and signal-check order: PASS")
|
||||
|
||||
text = body("_PyObject_DictPointer")
|
||||
expected = '''
|
||||
Py_ssize_t dictoffset;
|
||||
PyTypeObject *tp = Py_TYPE(obj);
|
||||
|
||||
if (tp->tp_flags & Py_TPFLAGS_MANAGED_DICT) {
|
||||
return _PyObject_ManagedDictPointer(obj);
|
||||
}
|
||||
dictoffset = tp->tp_dictoffset;
|
||||
if (dictoffset == 0)
|
||||
return NULL;
|
||||
if (dictoffset < 0) {
|
||||
Py_ssize_t tsize = Py_SIZE(obj);
|
||||
size_t size;
|
||||
if (tsize < 0) {
|
||||
tsize = -tsize;
|
||||
}
|
||||
size = _PyObject_VAR_SIZE(tp, tsize);
|
||||
assert(size <= (size_t)PY_SSIZE_T_MAX);
|
||||
dictoffset += (Py_ssize_t)size;
|
||||
|
||||
_PyObject_ASSERT(obj, dictoffset > 0);
|
||||
_PyObject_ASSERT(obj, dictoffset % SIZEOF_VOID_P == 0);
|
||||
}
|
||||
return (PyObject **) ((char *)obj + dictoffset);
|
||||
'''
|
||||
assert text.split() == expected.split(), (
|
||||
"_PyObject_DictPointer must hoist only size to the block's opening declarations "
|
||||
"and preserve the size expression and statement order"
|
||||
)
|
||||
print("object _PyObject_DictPointer C89 size declaration and offset calculation order: PASS")
|
||||
|
||||
Reference in New Issue
Block a user