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>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-29 17:44:05 +00:00
parent b198f511d2
commit 42e2356c88
367 changed files with 3520 additions and 3520 deletions

View File

@@ -62,7 +62,7 @@ static inline TyObject *
PyObject_CallMethodNoArgs(TyObject *self, TyObject *name)
{
size_t nargsf = 1 | PY_VECTORCALL_ARGUMENTS_OFFSET;
return PyObject_VectorcallMethod(name, &self, nargsf, _Ty_NULL);
return PyObject_VectorcallMethod(name, &self, nargsf, _Py_NULL);
}
static inline TyObject *
@@ -71,7 +71,7 @@ PyObject_CallMethodOneArg(TyObject *self, TyObject *name, TyObject *arg)
TyObject *args[2] = {self, arg};
size_t nargsf = 2 | PY_VECTORCALL_ARGUMENTS_OFFSET;
assert(arg != NULL);
return PyObject_VectorcallMethod(name, args, nargsf, _Ty_NULL);
return PyObject_VectorcallMethod(name, args, nargsf, _Py_NULL);
}
/* Guess the size of object 'o' using len(o) or o.__length_hint__().

View File

@@ -15,7 +15,7 @@ PyAPI_DATA(char) _PyByteArray_empty_string[];
/* Macros and static inline functions, trading safety for speed */
#define _PyByteArray_CAST(op) \
(assert(TyByteArray_Check(op)), _Ty_CAST(PyByteArrayObject*, op))
(assert(TyByteArray_Check(op)), _Py_CAST(PyByteArrayObject*, op))
static inline char* TyByteArray_AS_STRING(TyObject *op)
{

View File

@@ -18,7 +18,7 @@ PyAPI_FUNC(int) _TyBytes_Resize(TyObject **, Ty_ssize_t);
/* Macros and static inline functions, trading safety for speed */
#define _TyBytes_CAST(op) \
(assert(TyBytes_Check(op)), _Ty_CAST(PyBytesObject*, op))
(assert(TyBytes_Check(op)), _Py_CAST(PyBytesObject*, op))
static inline char* TyBytes_AS_STRING(TyObject *op)
{

View File

@@ -25,7 +25,7 @@ static inline TyObject* TyCell_GET(TyObject *op) {
TyObject *res;
PyCellObject *cell;
assert(TyCell_Check(op));
cell = _Ty_CAST(PyCellObject*, op);
cell = _Py_CAST(PyCellObject*, op);
Ty_BEGIN_CRITICAL_SECTION(cell);
res = cell->ob_ref;
Ty_END_CRITICAL_SECTION();
@@ -36,7 +36,7 @@ static inline TyObject* TyCell_GET(TyObject *op) {
static inline void TyCell_SET(TyObject *op, TyObject *value) {
PyCellObject *cell;
assert(TyCell_Check(op));
cell = _Ty_CAST(PyCellObject*, op);
cell = _Py_CAST(PyCellObject*, op);
Ty_BEGIN_CRITICAL_SECTION(cell);
cell->ob_ref = value;
Ty_END_CRITICAL_SECTION();

View File

@@ -27,7 +27,7 @@ PyAPI_FUNC(TyObject *) TyMethod_Function(TyObject *);
PyAPI_FUNC(TyObject *) TyMethod_Self(TyObject *);
#define _PyMethod_CAST(meth) \
(assert(TyMethod_Check(meth)), _Ty_CAST(PyMethodObject*, meth))
(assert(TyMethod_Check(meth)), _Py_CAST(PyMethodObject*, meth))
/* Static inline functions for direct access to these values.
Type checks are *not* done, so use with care. */
@@ -55,7 +55,7 @@ PyAPI_FUNC(TyObject *) PyInstanceMethod_Function(TyObject *);
#define _PyInstanceMethod_CAST(meth) \
(assert(PyInstanceMethod_Check(meth)), \
_Ty_CAST(PyInstanceMethodObject*, meth))
_Py_CAST(PyInstanceMethodObject*, meth))
/* Static inline function for direct access to these values.
Type checks are *not* done, so use with care. */

View File

@@ -33,7 +33,7 @@ typedef enum {
* passed to the watch callback is the now-current contextvars.Context
* object, or None if no context is current.
*/
Ty_CONTEXT_SWITCHED = 1,
Py_CONTEXT_SWITCHED = 1,
} PyContextEvent;
/*

View File

@@ -53,7 +53,7 @@ PyAPI_FUNC(int) TyDict_SetDefaultRef(TyObject *mp, TyObject *key, TyObject *defa
static inline Ty_ssize_t TyDict_GET_SIZE(TyObject *op) {
PyDictObject *mp;
assert(TyDict_Check(op));
mp = _Ty_CAST(PyDictObject*, op);
mp = _Py_CAST(PyDictObject*, op);
#ifdef Ty_GIL_DISABLED
return _Ty_atomic_load_ssize_relaxed(&mp->ma_used);
#else

View File

@@ -8,7 +8,7 @@ typedef struct {
} PyFloatObject;
#define _TyFloat_CAST(op) \
(assert(TyFloat_Check(op)), _Ty_CAST(PyFloatObject*, op))
(assert(TyFloat_Check(op)), _Py_CAST(PyFloatObject*, op))
// Static inline version of TyFloat_AsDouble() trading safety for speed.
// It doesn't check if op is a double object.

View File

@@ -83,7 +83,7 @@ PyAPI_FUNC(TyObject *) TyFunction_GetAnnotations(TyObject *);
PyAPI_FUNC(int) TyFunction_SetAnnotations(TyObject *, TyObject *);
#define _PyFunction_CAST(func) \
(assert(TyFunction_Check(func)), _Ty_CAST(PyFunctionObject*, func))
(assert(TyFunction_Check(func)), _Py_CAST(PyFunctionObject*, func))
/* Static inline functions for direct access to these values.
Type checks are *not* done, so use with care. */

View File

@@ -23,7 +23,7 @@ typedef struct {
/* Cast argument to PyListObject* type. */
#define _TyList_CAST(op) \
(assert(TyList_Check(op)), _Ty_CAST(PyListObject*, (op)))
(assert(TyList_Check(op)), _Py_CAST(PyListObject*, (op)))
// Macros and static inline functions, trading safety for speed

View File

@@ -3,7 +3,7 @@
#endif
#define _TyLong_CAST(op) \
(assert(TyLong_Check(op)), _Ty_CAST(PyLongObject*, (op)))
(assert(TyLong_Check(op)), _Py_CAST(PyLongObject*, (op)))
PyAPI_FUNC(TyObject*) TyLong_FromUnicodeObject(TyObject *u, int base);

View File

@@ -35,7 +35,7 @@ typedef struct {
Ty_ssize_t ob_array[1]; /* shape, strides, suboffsets */
} PyMemoryViewObject;
#define _PyMemoryView_CAST(op) _Ty_CAST(PyMemoryViewObject*, op)
#define _PyMemoryView_CAST(op) _Py_CAST(PyMemoryViewObject*, op)
/* Get a pointer to the memoryview's private copy of the exporter's buffer. */
static inline Ty_buffer* TyMemoryView_GET_BUFFER(TyObject *op) {

View File

@@ -349,7 +349,7 @@ PyAPI_FUNC(TyObject *) _TyObject_FunctionStr(TyObject *);
#else
#define Ty_SETREF(dst, src) \
do { \
TyObject **_tmp_dst_ptr = _Ty_CAST(TyObject**, &(dst)); \
TyObject **_tmp_dst_ptr = _Py_CAST(TyObject**, &(dst)); \
TyObject *_tmp_old_dst = (*_tmp_dst_ptr); \
TyObject *_tmp_src = _TyObject_CAST(src); \
memcpy(_tmp_dst_ptr, &_tmp_src, sizeof(TyObject*)); \
@@ -371,7 +371,7 @@ PyAPI_FUNC(TyObject *) _TyObject_FunctionStr(TyObject *);
#else
#define Ty_XSETREF(dst, src) \
do { \
TyObject **_tmp_dst_ptr = _Ty_CAST(TyObject**, &(dst)); \
TyObject **_tmp_dst_ptr = _Py_CAST(TyObject**, &(dst)); \
TyObject *_tmp_old_dst = (*_tmp_dst_ptr); \
TyObject *_tmp_src = _TyObject_CAST(src); \
memcpy(_tmp_dst_ptr, &_tmp_src, sizeof(TyObject*)); \

View File

@@ -59,7 +59,7 @@ typedef struct {
} PySetObject;
#define _TySet_CAST(so) \
(assert(PyAnySet_Check(so)), _Ty_CAST(PySetObject*, so))
(assert(PyAnySet_Check(so)), _Py_CAST(PySetObject*, so))
static inline Ty_ssize_t TySet_GET_SIZE(TyObject *so) {
#ifdef Ty_GIL_DISABLED

View File

@@ -16,7 +16,7 @@ PyAPI_FUNC(int) _TyTuple_Resize(TyObject **, Ty_ssize_t);
/* Cast argument to PyTupleObject* type. */
#define _TyTuple_CAST(op) \
(assert(TyTuple_Check(op)), _Ty_CAST(PyTupleObject*, (op)))
(assert(TyTuple_Check(op)), _Py_CAST(PyTupleObject*, (op)))
// Macros and static inline functions, trading safety for speed

View File

@@ -186,13 +186,13 @@ typedef struct {
#define _PyASCIIObject_CAST(op) \
(assert(TyUnicode_Check(op)), \
_Ty_CAST(PyASCIIObject*, (op)))
_Py_CAST(PyASCIIObject*, (op)))
#define _PyCompactUnicodeObject_CAST(op) \
(assert(TyUnicode_Check(op)), \
_Ty_CAST(PyCompactUnicodeObject*, (op)))
_Py_CAST(PyCompactUnicodeObject*, (op)))
#define _PyUnicodeObject_CAST(op) \
(assert(TyUnicode_Check(op)), \
_Ty_CAST(PyUnicodeObject*, (op)))
_Py_CAST(PyUnicodeObject*, (op)))
/* --- Flexible String Representation Helper Macros (PEP 393) -------------- */
@@ -216,7 +216,7 @@ static inline unsigned int TyUnicode_CHECK_INTERNED(TyObject *op) {
#define TyUnicode_CHECK_INTERNED(op) TyUnicode_CHECK_INTERNED(_TyObject_CAST(op))
/* For backward compatibility. Soft-deprecated. */
static inline unsigned int TyUnicode_IS_READY(TyObject* Ty_UNUSED(op)) {
static inline unsigned int TyUnicode_IS_READY(TyObject* Py_UNUSED(op)) {
return 1;
}
#define TyUnicode_IS_READY(op) TyUnicode_IS_READY(_TyObject_CAST(op))
@@ -257,7 +257,7 @@ PyAPI_FUNC(int) TyUnicode_KIND(TyObject *op);
// new compiler warnings on "kind < TyUnicode_KIND(str)" (compare signed and
// unsigned numbers) where kind type is an int or on
// "unsigned int kind = TyUnicode_KIND(str)" (cast signed to unsigned).
#define TyUnicode_KIND(op) _Ty_RVALUE(_PyASCIIObject_CAST(op)->state.kind)
#define TyUnicode_KIND(op) _Py_RVALUE(_PyASCIIObject_CAST(op)->state.kind)
/* Return a void pointer to the raw unicode buffer. */
static inline void* _TyUnicode_COMPACT_DATA(TyObject *op) {
@@ -324,7 +324,7 @@ static inline void TyUnicode_WRITE(int kind, void *data,
}
}
#define TyUnicode_WRITE(kind, data, index, value) \
TyUnicode_WRITE(_Ty_STATIC_CAST(int, kind), _Ty_CAST(void*, data), \
TyUnicode_WRITE(_Ty_STATIC_CAST(int, kind), _Py_CAST(void*, data), \
(index), _Ty_STATIC_CAST(Ty_UCS4, value))
/* Read a code point from the string's canonical representation. No checks
@@ -408,7 +408,7 @@ PyAPI_FUNC(TyObject*) TyUnicode_New(
);
/* For backward compatibility. Soft-deprecated. */
static inline int TyUnicode_READY(TyObject* Ty_UNUSED(op))
static inline int TyUnicode_READY(TyObject* Py_UNUSED(op))
{
return 0;
}

View File

@@ -43,7 +43,7 @@ struct _PyWeakReference {
PyAPI_FUNC(void) _TyWeakref_ClearRef(PyWeakReference *self);
#define _TyWeakref_CAST(op) \
(assert(PyWeakref_Check(op)), _Ty_CAST(PyWeakReference*, (op)))
(assert(PyWeakref_Check(op)), _Py_CAST(PyWeakReference*, (op)))
// Test if a weak reference is dead.
PyAPI_FUNC(int) PyWeakref_IsDead(TyObject *ref);