test(cpythontest): PyUnicode_GetLength(Py_ssize_t=64位) 改用 t.CPtrDiffT 接收,并校正 cpython.vp 三处应为 64 位的返回类型

This commit is contained in:
TermiNexus committed 2026-10-13 10:08:25 +08:00
1 parent e5e4163167
commit 4e279d806f
2 files changed
+6 -4

No files matched your search

+3 -3
View File
@@ -109,8 +109,8 @@ extern def PyLong_FromSize_t(v: sizet) -> PyObject*
extern def PyLong_FromDouble(v: double) -> PyObject*
extern def PyLong_AsLong(obj: PyObject*) -> int
extern def PyLong_AsUnsignedLong(obj: PyObject*) -> t.CUnsignedLong
extern def PyLong_AsLongLong(obj: PyObject*) -> t.CLong
extern def PyLong_AsUnsignedLongLong(obj: PyObject*) -> t.CUnsignedLong
extern def PyLong_AsLongLong(obj: PyObject*) -> t.CLongLong
extern def PyLong_AsUnsignedLongLong(obj: PyObject*) -> t.CUnsignedLongLong
extern def PyLong_AsDouble(obj: PyObject*) -> double
extern def PyLong_AsSsize_t(obj: PyObject*) -> t.CPtrDiffT
extern def PyLong_AsSize_t(obj: PyObject*) -> sizet
@@ -220,7 +220,7 @@ extern def PyObject_IsTrue(obj: PyObject*) -> int
extern def PyObject_Not(obj: PyObject*) -> int
extern def PyObject_RichCompare(o1: PyObject*, o2: PyObject*, opid: int) -> PyObject*
extern def PyObject_RichCompareBool(o1: PyObject*, o2: PyObject*, opid: int) -> int
extern def PyObject_Hash(obj: PyObject*) -> t.CLong
extern def PyObject_Hash(obj: PyObject*) -> t.CPtrDiffT
extern def PyObject_Length(obj: PyObject*) -> sizet
extern def PyObject_GetItem(obj: PyObject*, key: PyObject*) -> PyObject*
extern def PyObject_SetItem(obj: PyObject*, key: PyObject*, val: PyObject*) -> int
+3 -1
View File
@@ -68,7 +68,9 @@ def test_string_operations():
printf(" PyUnicode_FromString -> %s\n", utf8)
# String length
length: CLong = cpython.PyUnicode_GetLength(py_s1)
# PyUnicode_GetLength 返回 CPython 的 Py_ssize_t(= ptrdiff_t,64 位);CLong 在本目标
# (x86_64-pc-windows-gnu / LLP64) 只有 32 位,用 CLong 接收会触发「隐式窄化禁止」。
length: t.CPtrDiffT = cpython.PyUnicode_GetLength(py_s1)
testcheck.check(length == 13, "GetLength == 13", "GetLength == 13")
# String concat