Repository navigation
test_*_code functions in _testcapi/getargs.c have memory leaks #110572
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortestsTests in the Lib/test dirTests in the Lib/test dir
on Oct 9, 2023 Are these tests still needed?
's','L', and'k'are still mentioned in https://docs.python.org/3.12/howto/clinic.html#how-to-use-real-argument-clinic-converters-instead-of-legacy-convertersSo, I guess we still need to make sure that they are supported and work correctly.
They are even not deprecated, just called "legacy".I mean that they are tested in
Lib/test/test_capi/test_getargs.pyusing wrappers likegetargs_k(). And #110628 adds tests for functions likePyLong_AsUnsignedLongMask().In this case, yes. We can move some logic from these tests to
test_long.py.Things that right now are not tested in
test_long(this list might be not full):test_k_code:PyLong_FromString("FFFFFFFFFFFFFFFFFFFFFFFF", NULL, 16)test_k_code:PyLong_FromString("-FFFFFFFF000000000000000042", NULL, 16)test_s_code:getargs_s('t\xeate')(however,'abc\xe9'is tested)test_s_code:getargs_z('t\xeate')(however,'abc\xe9'is tested)
So, do you agree on this plan?
- I convert this PR to delete these tests, it will be in a draft state for now
- We ensure that all checks from
test_*_codeare in eithertest_long.pyor intest_getargs.py - We merge your PR with
test_long.pyand possible PRs totest_getargs.py - We merge my PR from
1.with these tests removed
- added a commit that references this issue
on Oct 21, 2023 I merged your PR, and it will be backported to 3.12. In main we should consider removing this tests.
PyLong_FromString("FFFFFFFFFFFFFFFFFFFFFFFF", NULL, 16)is just a way to create a long int for the following test ofPyLong_AsUnsignedLongMask(). There are already tests forPyLong_AsUnsignedLongMask()for argument outside of 0..ULONG_MAX. There are also similar tests for the "k" format unit. I think that all this can be deleted.- added a commit that references this issue
on Oct 21, 2023 - added a commit that references this issue
on Oct 23, 2023 Thanks for the PRs.
Bug report
I don't think it is very important, since this is just a test, but why have it when it is spotted?
test_k_code:cpython/Modules/_testcapi/getargs.c
Lines 331 to 398 in 326c6c4
On errors
tupleis not decrefed.Also, note these lines:
cpython/Modules/_testcapi/getargs.c
Lines 358 to 374 in 326c6c4
Here' we leave a
tupleis a semi-broken state. Its 0'th item has a reference count of 0.We should also recreate a
tuplehere with the new items.test_L_codealso has this problem.cpython/Modules/_testcapi/getargs.c
Lines 684 to 732 in 326c6c4
On errors
tupleis not decrefed. Andnumis re-assigned withouttuplecleanup.cpython/Modules/_testcapi/getargs.c
Lines 734 to 767 in 326c6c4
As well,
tupleis leaked on errors.I have a PR ready.
Linked PRs
test_*_codein_testcapi/getargs.c#110573test_*from_testcapi/getargs.c#111214