Skip to content

gh-106320: Remove private _PyContext_NewHamtForTests() #108434

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
merged 1 commit into from
Aug 24, 2023
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: 0 additions & 4 deletions Include/cpython/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ PyAPI_FUNC(PyObject *) PyContextVar_Set(PyObject *var, PyObject *value);
PyAPI_FUNC(int) PyContextVar_Reset(PyObject *var, PyObject *token);


/* This method is exposed only for CPython tests. Don not use it. */
PyAPI_FUNC(PyObject *) _PyContext_NewHamtForTests(void);


#ifdef __cplusplus
}
#endif
Expand Down
5 changes: 5 additions & 0 deletions Include/internal/pycore_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,9 @@ struct _pycontexttokenobject {
};


// _testinternalcapi.hamt() used by tests.
// Export for '_testcapi' shared extension
PyAPI_FUNC(PyObject*) _PyContext_NewHamtForTests(void);


#endif /* !Py_INTERNAL_CONTEXT_H */
4 changes: 2 additions & 2 deletions Lib/test/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from test.support import threading_helper

try:
from _testcapi import hamt
from _testinternalcapi import hamt
except ImportError:
hamt = None

Expand Down Expand Up @@ -431,7 +431,7 @@ class EqError(Exception):
pass


@unittest.skipIf(hamt is None, '_testcapi lacks "hamt()" function')
@unittest.skipIf(hamt is None, '_testinternalcapi.hamt() not available')
class HamtTest(unittest.TestCase):

def test_hashkey_helper_1(self):
Expand Down
8 changes: 0 additions & 8 deletions Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2125,13 +2125,6 @@ test_pythread_tss_key_state(PyObject *self, PyObject *args)
}


static PyObject*
new_hamt(PyObject *self, PyObject *args)
{
return _PyContext_NewHamtForTests();
}


/* def bad_get(self, obj, cls):
cls()
return repr(self)
Expand Down Expand Up @@ -3626,7 +3619,6 @@ static PyMethodDef TestMethods[] = {
{"W_STOPCODE", py_w_stopcode, METH_VARARGS},
#endif
{"test_pythread_tss_key_state", test_pythread_tss_key_state, METH_VARARGS},
{"hamt", new_hamt, METH_NOARGS},
{"bad_get", _PyCFunction_CAST(bad_get), METH_FASTCALL},
#ifdef Py_REF_DEBUG
{"negative_refcount", negative_refcount, METH_NOARGS},
Expand Down
11 changes: 10 additions & 1 deletion Modules/_testinternalcapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
#include "pycore_atomic_funcs.h" // _Py_atomic_int_get()
#include "pycore_bitutils.h" // _Py_bswap32()
#include "pycore_bytesobject.h" // _PyBytes_Find()
#include "pycore_compile.h" // _PyCompile_CodeGen, _PyCompile_OptimizeCfg, _PyCompile_Assemble, _PyCompile_CleanDoc
#include "pycore_ceval.h" // _PyEval_AddPendingCall()
#include "pycore_compile.h" // _PyCompile_CodeGen()
#include "pycore_context.h" // _PyContext_NewHamtForTests()
#include "pycore_dict.h" // _PyDictOrValues_GetValues()
#include "pycore_fileutils.h" // _Py_normpath()
#include "pycore_frame.h" // _PyInterpreterFrame
Expand Down Expand Up @@ -1564,6 +1565,13 @@ get_object_dict_values(PyObject *self, PyObject *obj)
}


static PyObject*
new_hamt(PyObject *self, PyObject *args)
{
return _PyContext_NewHamtForTests();
}


static PyMethodDef module_functions[] = {
{"get_configs", get_configs, METH_NOARGS},
{"get_recursion_depth", get_recursion_depth, METH_NOARGS},
Expand Down Expand Up @@ -1628,6 +1636,7 @@ static PyMethodDef module_functions[] = {
check_pyobject_uninitialized_is_freed, METH_NOARGS},
{"pymem_getallocatorsname", test_pymem_getallocatorsname, METH_NOARGS},
{"get_object_dict_values", get_object_dict_values, METH_O},
{"hamt", new_hamt, METH_NOARGS},
{NULL, NULL} /* sentinel */
};

Expand Down