mirror of https://github.com/python/cpython
gh-106320: Remove private _PyContext_NewHamtForTests() (#108434)
Move the function to the internal C API.
This commit is contained in:
parent
aa6f787faa
commit
480a337366
|
@ -67,10 +67,6 @@ PyAPI_FUNC(PyObject *) PyContextVar_Set(PyObject *var, PyObject *value);
|
||||||
PyAPI_FUNC(int) PyContextVar_Reset(PyObject *var, PyObject *token);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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 */
|
#endif /* !Py_INTERNAL_CONTEXT_H */
|
||||||
|
|
|
@ -9,7 +9,7 @@ import weakref
|
||||||
from test.support import threading_helper
|
from test.support import threading_helper
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from _testcapi import hamt
|
from _testinternalcapi import hamt
|
||||||
except ImportError:
|
except ImportError:
|
||||||
hamt = None
|
hamt = None
|
||||||
|
|
||||||
|
@ -431,7 +431,7 @@ class EqError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipIf(hamt is None, '_testcapi lacks "hamt()" function')
|
@unittest.skipIf(hamt is None, '_testinternalcapi.hamt() not available')
|
||||||
class HamtTest(unittest.TestCase):
|
class HamtTest(unittest.TestCase):
|
||||||
|
|
||||||
def test_hashkey_helper_1(self):
|
def test_hashkey_helper_1(self):
|
||||||
|
|
|
@ -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):
|
/* def bad_get(self, obj, cls):
|
||||||
cls()
|
cls()
|
||||||
return repr(self)
|
return repr(self)
|
||||||
|
@ -3626,7 +3619,6 @@ static PyMethodDef TestMethods[] = {
|
||||||
{"W_STOPCODE", py_w_stopcode, METH_VARARGS},
|
{"W_STOPCODE", py_w_stopcode, METH_VARARGS},
|
||||||
#endif
|
#endif
|
||||||
{"test_pythread_tss_key_state", test_pythread_tss_key_state, METH_VARARGS},
|
{"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},
|
{"bad_get", _PyCFunction_CAST(bad_get), METH_FASTCALL},
|
||||||
#ifdef Py_REF_DEBUG
|
#ifdef Py_REF_DEBUG
|
||||||
{"negative_refcount", negative_refcount, METH_NOARGS},
|
{"negative_refcount", negative_refcount, METH_NOARGS},
|
||||||
|
|
|
@ -13,8 +13,9 @@
|
||||||
#include "pycore_atomic_funcs.h" // _Py_atomic_int_get()
|
#include "pycore_atomic_funcs.h" // _Py_atomic_int_get()
|
||||||
#include "pycore_bitutils.h" // _Py_bswap32()
|
#include "pycore_bitutils.h" // _Py_bswap32()
|
||||||
#include "pycore_bytesobject.h" // _PyBytes_Find()
|
#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_ceval.h" // _PyEval_AddPendingCall()
|
||||||
|
#include "pycore_compile.h" // _PyCompile_CodeGen()
|
||||||
|
#include "pycore_context.h" // _PyContext_NewHamtForTests()
|
||||||
#include "pycore_dict.h" // _PyDictOrValues_GetValues()
|
#include "pycore_dict.h" // _PyDictOrValues_GetValues()
|
||||||
#include "pycore_fileutils.h" // _Py_normpath()
|
#include "pycore_fileutils.h" // _Py_normpath()
|
||||||
#include "pycore_frame.h" // _PyInterpreterFrame
|
#include "pycore_frame.h" // _PyInterpreterFrame
|
||||||
|
@ -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[] = {
|
static PyMethodDef module_functions[] = {
|
||||||
{"get_configs", get_configs, METH_NOARGS},
|
{"get_configs", get_configs, METH_NOARGS},
|
||||||
{"get_recursion_depth", get_recursion_depth, METH_NOARGS},
|
{"get_recursion_depth", get_recursion_depth, METH_NOARGS},
|
||||||
|
@ -1628,6 +1636,7 @@ static PyMethodDef module_functions[] = {
|
||||||
check_pyobject_uninitialized_is_freed, METH_NOARGS},
|
check_pyobject_uninitialized_is_freed, METH_NOARGS},
|
||||||
{"pymem_getallocatorsname", test_pymem_getallocatorsname, METH_NOARGS},
|
{"pymem_getallocatorsname", test_pymem_getallocatorsname, METH_NOARGS},
|
||||||
{"get_object_dict_values", get_object_dict_values, METH_O},
|
{"get_object_dict_values", get_object_dict_values, METH_O},
|
||||||
|
{"hamt", new_hamt, METH_NOARGS},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue