Skip to content
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

gh-93274: Disable Limited API tests with Py_TRACE_REFS #95796

Merged
merged 1 commit into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Lib/test/test_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import itertools
import gc
import contextlib
import sys


class BadStr(str):
Expand Down Expand Up @@ -759,6 +760,9 @@ def __call__(self, *args):
self.assertEqual(expected, meth(*args1, **kwargs))
self.assertEqual(expected, wrapped(*args, **kwargs))

@unittest.skipIf(
hasattr(sys, 'getobjects'),
"Limited API is not compatible with Py_TRACE_REFS")
def test_vectorcall_limited(self):
from _testcapi import pyobject_vectorcall
obj = _testcapi.LimitedVectorCallClass()
Expand Down
15 changes: 15 additions & 0 deletions Modules/_testcapi/vectorcall_limited.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
#include "pyconfig.h" // Py_TRACE_REFS

#ifdef Py_TRACE_REFS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to move this #ifdef in _testcapimodule.c instead.


// Py_TRACE_REFS is incompatible with Limited API
#include "parts.h"
int
_PyTestCapi_Init_VectorcallLimited(PyObject *m) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest putting an #ifdef on the _PyTestCapi_Init_VectorcallLimited() call in _testcapimodole.c instead of defining a no-op function.

Maybe define somewhere a macro to decide if vectorcall is tested or not? Something like:

#ifndef Py_TRACE_REFS
#  define TEST_VECTORCALL
#endif

return 0;
}

#else

#define Py_LIMITED_API 0x030c0000 // 3.12
#include "parts.h"
#include "structmember.h" // PyMemberDef
Expand Down Expand Up @@ -75,3 +88,5 @@ _PyTestCapi_Init_VectorcallLimited(PyObject *m) {

return 0;
}

#endif // Py_TRACE_REFS