port: advance VC6 typeobject frontier and preserve regression coverage
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Check frozenset_vectorcall's C89 declarations and evaluation order."""
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
source = Path(sys.argv[1]).read_text()
|
||||
match = re.search(
|
||||
r"static PyObject \*\nfrozenset_vectorcall\(PyObject \*type, PyObject \* const\*args,"
|
||||
r"\s*size_t nargsf, PyObject \*kwnames\)\n\{(.*?)\n\}",
|
||||
source,
|
||||
re.S,
|
||||
)
|
||||
assert match, "frozenset_vectorcall not found"
|
||||
body = match.group(1)
|
||||
assert re.match(r"\s*Py_ssize_t nargs;\s*PyObject \*iterable;", body), (
|
||||
"nargs and iterable must be declared without initializers in the initial block"
|
||||
)
|
||||
expected = """
|
||||
Py_ssize_t nargs;
|
||||
PyObject *iterable;
|
||||
|
||||
if (!_PyArg_NoKwnames("frozenset", kwnames)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nargs = PyVectorcall_NARGS(nargsf);
|
||||
if (!_PyArg_CheckPositional("frozenset", nargs, 0, 1)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
iterable = (nargs ? args[0] : NULL);
|
||||
return make_new_frozenset(_PyType_CAST(type), iterable);
|
||||
"""
|
||||
assert re.sub(r"\s+", "", body) == re.sub(r"\s+", "", expected), (
|
||||
"preserve keyword rejection, nargs evaluation, positional rejection, guarded "
|
||||
"iterable evaluation, and construction in their original order"
|
||||
)
|
||||
print("frozenset_vectorcall C89 declarations and evaluation order: PASS")
|
||||
Reference in New Issue
Block a user