-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-96002: Add functional test for Argument Clinic #96178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
erlend-aasland
merged 35 commits into
python:main
from
colorfulappl:test_clinic_functionality
Nov 21, 2022
Merged
Changes from 5 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
f00bb03
Support functional test for Argument Clinic
colorfulappl a59e304
📜🤖 Added by blurb_it.
blurb-it[bot] 2bd331e
Revert "Support functional test for Argument Clinic"
colorfulappl fac5b77
Add functional test for Argument Clinic
colorfulappl 962434c
Add testcases written in C
colorfulappl b93b2ae
Rename _testclinicfunctionality.c to _testclinic.c
colorfulappl 35c5f13
Add _testclinic to stdlib IGNORE list
colorfulappl 86703de
Merge TestClinicFunctionalityC class into TestClinicFunctionality
colorfulappl e66d60b
Format code in _testclinic.c
colorfulappl f1fb377
Merge test_clinic_functionality.py into test_clinic.py
colorfulappl 449c8fe
Simplify testcases
colorfulappl 1553574
Merge branch 'main' into test_clinic_functionality
colorfulappl 81fe77b
Add more testcases
colorfulappl 7c269d0
Rename class TestClinicFunctionality to ClinicFunctionalTest
colorfulappl a3a3455
Fix UB problem
colorfulappl 80ba71a
Fix refleaks
colorfulappl cf77785
Clean code
colorfulappl 10ce3c7
Add PoC of GH-99233
colorfulappl 2cc6c0a
Add PoC of GH-99240
colorfulappl 6a2d334
Delete test cases which fail this test
colorfulappl d82ef72
Merge branch 'main' into test_clinic_functionality
colorfulappl b27b43d
Rerun `make regen-all`
colorfulappl 1cae160
Fix leaking
colorfulappl fb6d3be
Fix code style
colorfulappl fd1ed14
Merge branch 'main' into test_clinic_functionality
colorfulappl e82c88a
Rerun `make regen-all`
colorfulappl 598568c
Fix object leaking and code style
colorfulappl dd43f24
Change argument release order
colorfulappl 325e35b
Rename macro
colorfulappl 967dda6
Update news
colorfulappl d568683
Fix object leaking
colorfulappl ce337e8
Remove unnecessary logic
colorfulappl 3314465
Merge branch 'main' into test_clinic_functionality
colorfulappl 68277c5
Merge branch 'main' into test_clinic_functionality
colorfulappl da0789f
Merge branch 'main' into test_clinic_functionality
colorfulappl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import unittest | ||
from test.support import import_helper | ||
|
||
ac_tester = import_helper.import_module('_testclinicfunctionality') | ||
|
||
|
||
class TestClinicFunctionality(unittest.TestCase): | ||
def test_gh_32092_oob(self): | ||
res = ac_tester.gh_32092_oob(1, 2, 3, 4, kw1=5, kw2=6) | ||
expect = (1, 2, (3, 4), 5, 6) | ||
self.assertEqual(res, expect) | ||
|
||
def test_gh_32092_kw_pass(self): | ||
res = ac_tester.gh_32092_kw_pass(1, 2, 3) | ||
expect = (1, (2, 3), None) | ||
self.assertEqual(res, expect) | ||
|
||
|
||
class TestClinicFunctionalityC(unittest.TestCase): | ||
locals().update((name, getattr(ac_tester, name)) | ||
for name in dir(ac_tester) if name.startswith('test_')) | ||
1 change: 1 addition & 0 deletions
1
Misc/NEWS.d/next/Tests/2022-08-22-15-49-14.gh-issue-96002.4UE9UE.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add functional test (``test_clinic_functionality``) for Argument Clinic. | ||
colorfulappl marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
#ifndef Py_BUILD_CORE_BUILTIN | ||
# define Py_BUILD_CORE_MODULE 1 | ||
#endif | ||
|
||
/* Always enable assertions */ | ||
#undef NDEBUG | ||
|
||
#define PY_SSIZE_T_CLEAN | ||
|
||
#include "Python.h" | ||
|
||
#include "clinic/_testclinicfunctionality.c.h" | ||
|
||
/*[clinic input] | ||
module _testclinicfunctionality | ||
[clinic start generated code]*/ | ||
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=19bd80db1aefb188]*/ | ||
|
||
/*[clinic input] | ||
test_empty_function | ||
|
||
[clinic start generated code]*/ | ||
|
||
static PyObject * | ||
test_empty_function_impl(PyObject *module) | ||
/*[clinic end generated code: output=0f8aeb3ddced55cb input=0dd7048651ad4ae4]*/ | ||
{ | ||
Py_RETURN_NONE; | ||
}; | ||
|
||
/*[clinic input] | ||
gh_32092_oob | ||
|
||
pos1: object | ||
pos2: object | ||
*varargs: object | ||
kw1: object = None | ||
kw2: object = None | ||
|
||
Proof-of-concept of GH-32092 OOB bug. | ||
|
||
Array index out-of-bound bug in function | ||
`_PyArg_UnpackKeywordsWithVararg` . | ||
|
||
Calling this function by gh_32092_oob(1, 2, 3, 4, kw1=5, kw2=6) | ||
to trigger this bug (crash). | ||
Expected return: (1, 2, (3, 4), 5, 6) | ||
|
||
[clinic start generated code]*/ | ||
|
||
static PyObject * | ||
gh_32092_oob_impl(PyObject *module, PyObject *pos1, PyObject *pos2, | ||
PyObject *varargs, PyObject *kw1, PyObject *kw2) | ||
/*[clinic end generated code: output=ee259c130054653f input=91d8e227acf93b02]*/ | ||
{ | ||
PyObject *tuple = PyTuple_New(5); | ||
PyTuple_SET_ITEM(tuple, 0, Py_NewRef(pos1)); | ||
PyTuple_SET_ITEM(tuple, 1, Py_NewRef(pos2)); | ||
PyTuple_SET_ITEM(tuple, 2, Py_NewRef(varargs)); | ||
PyTuple_SET_ITEM(tuple, 3, Py_NewRef(kw1)); | ||
PyTuple_SET_ITEM(tuple, 4, Py_NewRef(kw2)); | ||
return tuple; | ||
} | ||
erlend-aasland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/*[clinic input] | ||
gh_32092_kw_pass | ||
|
||
pos: object | ||
*args: object | ||
kw: object = None | ||
|
||
Proof-of-concept of GH-32092 keyword args passing bug. | ||
|
||
The calculation of `noptargs` in AC-generated function | ||
`builtin_kw_pass_poc` is incorrect. | ||
|
||
Calling this function by gh_32092_kw_pass(1, 2, 3) | ||
to trigger this bug (crash). | ||
Expected return: (1, (2, 3), None) | ||
|
||
[clinic start generated code]*/ | ||
|
||
static PyObject * | ||
gh_32092_kw_pass_impl(PyObject *module, PyObject *pos, PyObject *args, | ||
PyObject *kw) | ||
/*[clinic end generated code: output=4a2bbe4f7c8604e9 input=5fc48f72f49193b6]*/ | ||
{ | ||
PyObject *tuple = PyTuple_New(3); | ||
PyTuple_SET_ITEM(tuple, 0, Py_NewRef(pos)); | ||
PyTuple_SET_ITEM(tuple, 1, Py_NewRef(args)); | ||
PyTuple_SET_ITEM(tuple, 2, Py_NewRef(kw)); | ||
return tuple; | ||
} | ||
erlend-aasland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
static PyMethodDef tester_methods[] = { | ||
TEST_EMPTY_FUNCTION_METHODDEF | ||
GH_32092_OOB_METHODDEF | ||
GH_32092_KW_PASS_METHODDEF | ||
{NULL, NULL} | ||
}; | ||
|
||
static struct PyModuleDef _testclinicfunctionality_module = { | ||
PyModuleDef_HEAD_INIT, | ||
"_testclinicfunctionality", | ||
NULL, | ||
0, | ||
tester_methods, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL | ||
colorfulappl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
PyMODINIT_FUNC | ||
PyInit__testclinicfunctionality(void) | ||
{ | ||
return PyModule_Create(&_testclinicfunctionality_module); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.