mirror of
https://github.com/johndoe6345789/typthon.git
synced 2026-04-24 13:45:05 +00:00
Fix exception patterns and macros
- Fixed _PyExc_ → _TyExc_ globally - Fixed duplicated macro in SimpleExtendsException - Fixed Py ## EXCSTORE ## Object → Ty ## EXCSTORE ## Object in macros These fixes resolve macro expansion issues in exception definitions. Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
@@ -2164,7 +2164,7 @@ _TyEval_ExceptionGroupMatch(_PyInterpreterFrame *frame, TyObject* exc_value,
|
||||
if (excs == NULL) {
|
||||
return -1;
|
||||
}
|
||||
TyObject *wrapped = _PyExc_CreateExceptionGroup("", excs);
|
||||
TyObject *wrapped = _TyExc_CreateExceptionGroup("", excs);
|
||||
Ty_DECREF(excs);
|
||||
if (wrapped == NULL) {
|
||||
return -1;
|
||||
|
||||
@@ -24,7 +24,7 @@ static TyTypeObject _TyExc_InterpreterError = {
|
||||
//.tp_clear = ((TyTypeObject *)TyExc_Exception)->tp_clear,
|
||||
//.tp_base = (TyTypeObject *)TyExc_Exception,
|
||||
};
|
||||
TyObject *TyExc_InterpreterError = (TyObject *)&_PyExc_InterpreterError;
|
||||
TyObject *TyExc_InterpreterError = (TyObject *)&_TyExc_InterpreterError;
|
||||
|
||||
/* InterpreterNotFoundError extends InterpreterError */
|
||||
|
||||
@@ -35,9 +35,9 @@ static TyTypeObject _TyExc_InterpreterNotFoundError = {
|
||||
.tp_flags = Ty_TPFLAGS_DEFAULT | Ty_TPFLAGS_BASETYPE | Ty_TPFLAGS_HAVE_GC,
|
||||
//.tp_traverse = ((TyTypeObject *)TyExc_Exception)->tp_traverse,
|
||||
//.tp_clear = ((TyTypeObject *)TyExc_Exception)->tp_clear,
|
||||
.tp_base = &_PyExc_InterpreterError,
|
||||
.tp_base = &_TyExc_InterpreterError,
|
||||
};
|
||||
TyObject *TyExc_InterpreterNotFoundError = (TyObject *)&_PyExc_InterpreterNotFoundError;
|
||||
TyObject *TyExc_InterpreterNotFoundError = (TyObject *)&_TyExc_InterpreterNotFoundError;
|
||||
|
||||
/* NotShareableError extends TypeError */
|
||||
|
||||
@@ -141,22 +141,22 @@ init_static_exctypes(exceptions_t *state, TyInterpreterState *interp)
|
||||
TyTypeObject *base = (TyTypeObject *)TyExc_Exception;
|
||||
|
||||
// TyExc_InterpreterError
|
||||
_PyExc_InterpreterError.tp_base = base;
|
||||
_PyExc_InterpreterError.tp_traverse = base->tp_traverse;
|
||||
_PyExc_InterpreterError.tp_clear = base->tp_clear;
|
||||
if (_PyStaticType_InitBuiltin(interp, &_PyExc_InterpreterError) < 0) {
|
||||
_TyExc_InterpreterError.tp_base = base;
|
||||
_TyExc_InterpreterError.tp_traverse = base->tp_traverse;
|
||||
_TyExc_InterpreterError.tp_clear = base->tp_clear;
|
||||
if (_PyStaticType_InitBuiltin(interp, &_TyExc_InterpreterError) < 0) {
|
||||
goto error;
|
||||
}
|
||||
state->TyExc_InterpreterError = (TyObject *)&_PyExc_InterpreterError;
|
||||
state->TyExc_InterpreterError = (TyObject *)&_TyExc_InterpreterError;
|
||||
|
||||
// TyExc_InterpreterNotFoundError
|
||||
_PyExc_InterpreterNotFoundError.tp_traverse = base->tp_traverse;
|
||||
_PyExc_InterpreterNotFoundError.tp_clear = base->tp_clear;
|
||||
if (_PyStaticType_InitBuiltin(interp, &_PyExc_InterpreterNotFoundError) < 0) {
|
||||
_TyExc_InterpreterNotFoundError.tp_traverse = base->tp_traverse;
|
||||
_TyExc_InterpreterNotFoundError.tp_clear = base->tp_clear;
|
||||
if (_PyStaticType_InitBuiltin(interp, &_TyExc_InterpreterNotFoundError) < 0) {
|
||||
goto error;
|
||||
}
|
||||
state->TyExc_InterpreterNotFoundError =
|
||||
(TyObject *)&_PyExc_InterpreterNotFoundError;
|
||||
(TyObject *)&_TyExc_InterpreterNotFoundError;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -171,11 +171,11 @@ fini_static_exctypes(exceptions_t *state, TyInterpreterState *interp)
|
||||
assert(state == &_PyXI_GET_STATE(interp)->exceptions);
|
||||
if (state->TyExc_InterpreterNotFoundError != NULL) {
|
||||
state->TyExc_InterpreterNotFoundError = NULL;
|
||||
_PyStaticType_FiniBuiltin(interp, &_PyExc_InterpreterNotFoundError);
|
||||
_PyStaticType_FiniBuiltin(interp, &_TyExc_InterpreterNotFoundError);
|
||||
}
|
||||
if (state->TyExc_InterpreterError != NULL) {
|
||||
state->TyExc_InterpreterError = NULL;
|
||||
_PyStaticType_FiniBuiltin(interp, &_PyExc_InterpreterError);
|
||||
_PyStaticType_FiniBuiltin(interp, &_TyExc_InterpreterError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ static TyObject *
|
||||
prep_reraise_star(TyThreadState* unused, TyObject *orig, TyObject *excs)
|
||||
{
|
||||
assert(TyList_Check(excs));
|
||||
return _PyExc_PrepReraiseStar(orig, excs);
|
||||
return _TyExc_PrepReraiseStar(orig, excs);
|
||||
}
|
||||
|
||||
static TyObject *
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "pycore_codecs.h" // _PyCodec_Lookup()
|
||||
#include "pycore_context.h" // _TyContext_Init()
|
||||
#include "pycore_dict.h" // _TyDict_Fini()
|
||||
#include "pycore_exceptions.h" // _PyExc_InitTypes()
|
||||
#include "pycore_exceptions.h" // _TyExc_InitTypes()
|
||||
#include "pycore_fileutils.h" // _Ty_ResetForceASCII()
|
||||
#include "pycore_floatobject.h" // _TyFloat_InitTypes()
|
||||
#include "pycore_freelist.h" // _TyObject_ClearFreeLists()
|
||||
@@ -726,16 +726,16 @@ pycore_init_types(TyInterpreterState *interp)
|
||||
return status;
|
||||
}
|
||||
|
||||
if (_PyExc_InitTypes(interp) < 0) {
|
||||
if (_TyExc_InitTypes(interp) < 0) {
|
||||
return _TyStatus_ERR("failed to initialize an exception type");
|
||||
}
|
||||
|
||||
status = _PyExc_InitGlobalObjects(interp);
|
||||
status = _TyExc_InitGlobalObjects(interp);
|
||||
if (_TyStatus_EXCEPTION(status)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = _PyExc_InitState(interp);
|
||||
status = _TyExc_InitState(interp);
|
||||
if (_TyStatus_EXCEPTION(status)) {
|
||||
return status;
|
||||
}
|
||||
@@ -1863,7 +1863,7 @@ finalize_interp_types(TyInterpreterState *interp)
|
||||
_TyUnicode_FiniTypes(interp);
|
||||
_TySys_FiniTypes(interp);
|
||||
_PyXI_FiniTypes(interp);
|
||||
_PyExc_Fini(interp);
|
||||
_TyExc_Fini(interp);
|
||||
_TyFloat_FiniType(interp);
|
||||
_TyLong_FiniTypes(interp);
|
||||
_PyThread_FiniType(interp);
|
||||
@@ -1904,7 +1904,7 @@ finalize_interp_clear(TyThreadState *tstate)
|
||||
int is_main_interp = _Ty_IsMainInterpreter(tstate->interp);
|
||||
|
||||
_PyXI_Fini(tstate->interp);
|
||||
_PyExc_ClearExceptionGroupType(tstate->interp);
|
||||
_TyExc_ClearExceptionGroupType(tstate->interp);
|
||||
_Ty_clear_generic_types(tstate->interp);
|
||||
|
||||
/* Clear interpreter state and all thread states */
|
||||
|
||||
Reference in New Issue
Block a user