Files
typthon/Modules/_testlimitedcapi/sys.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

57 lines
1.2 KiB
C

#include "parts.h"
#include "util.h"
static TyObject *
sys_getobject(TyObject *Py_UNUSED(module), TyObject *arg)
{
const char *name;
Ty_ssize_t size;
if (!TyArg_Parse(arg, "z#", &name, &size)) {
return NULL;
}
TyObject *result = TySys_GetObject(name);
if (result == NULL) {
result = TyExc_AttributeError;
}
return Ty_NewRef(result);
}
static TyObject *
sys_setobject(TyObject *Py_UNUSED(module), TyObject *args)
{
const char *name;
Ty_ssize_t size;
TyObject *value;
if (!TyArg_ParseTuple(args, "z#O", &name, &size, &value)) {
return NULL;
}
NULLABLE(value);
RETURN_INT(TySys_SetObject(name, value));
}
static TyObject *
sys_getxoptions(TyObject *Py_UNUSED(module), TyObject *Py_UNUSED(ignored))
{
TyObject *result = TySys_GetXOptions();
return Ty_XNewRef(result);
}
static TyMethodDef test_methods[] = {
{"sys_getobject", sys_getobject, METH_O},
{"sys_setobject", sys_setobject, METH_VARARGS},
{"sys_getxoptions", sys_getxoptions, METH_NOARGS},
{NULL},
};
int
_PyTestLimitedCAPI_Init_Sys(TyObject *m)
{
if (TyModule_AddFunctions(m, test_methods) < 0) {
return -1;
}
return 0;
}