Files
typthon/Modules/_testcapi/config.c
copilot-swe-agent[bot] 42e2356c88 Fix incorrect replacements in Py_ to Ty_ renaming
Fixed several macros and constants that should not have been renamed:
- _Py_CAST, _Py_NULL, _Py_RVALUE (internal utility macros)
- Py_UNUSED (unused parameter macro)
- Py_EQ, Py_NE, Py_LT, Py_LE, Py_GT, Py_GE (comparison constants)
- Py_RETURN_* macros (NONE, TRUE, FALSE, NOTIMPLEMENTED, RICHCOMPARE)
- Py_READONLY, Py_ULL, Py_CONTEXT_SWITCHED
- TyGC_Head in generated clinic files

Build is still in progress with some remaining issues to resolve.

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
2025-12-29 17:44:05 +00:00

69 lines
1.3 KiB
C

#include "parts.h"
static TyObject *
_testcapi_config_get(TyObject *module, TyObject *name_obj)
{
const char *name;
if (TyArg_Parse(name_obj, "s", &name) < 0) {
return NULL;
}
return TyConfig_Get(name);
}
static TyObject *
_testcapi_config_getint(TyObject *module, TyObject *name_obj)
{
const char *name;
if (TyArg_Parse(name_obj, "s", &name) < 0) {
return NULL;
}
int value;
if (TyConfig_GetInt(name, &value) < 0) {
return NULL;
}
return TyLong_FromLong(value);
}
static TyObject *
_testcapi_config_names(TyObject *module, TyObject* Py_UNUSED(args))
{
return TyConfig_Names();
}
static TyObject *
_testcapi_config_set(TyObject *module, TyObject *args)
{
const char *name;
TyObject *value;
if (TyArg_ParseTuple(args, "sO", &name, &value) < 0) {
return NULL;
}
int res = TyConfig_Set(name, value);
if (res < 0) {
return NULL;
}
Py_RETURN_NONE;
}
static TyMethodDef test_methods[] = {
{"config_get", _testcapi_config_get, METH_O},
{"config_getint", _testcapi_config_getint, METH_O},
{"config_names", _testcapi_config_names, METH_NOARGS},
{"config_set", _testcapi_config_set, METH_VARARGS},
{NULL}
};
int
_PyTestCapi_Init_Config(TyObject *mod)
{
return TyModule_AddFunctions(mod, test_methods);
}