@@ -1970,7 +1970,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
1970
1970
1971
1971
TARGET (BEGIN_FINALLY ) {
1972
1972
/* Push NULL onto the stack for using it in END_FINALLY,
1973
- POP_FINALLY, WITH_CLEANUP_START and WITH_CLEANUP_FINISH .
1973
+ POP_FINALLY.
1974
1974
*/
1975
1975
PUSH (NULL );
1976
1976
FAST_DISPATCH ();
@@ -3048,116 +3048,6 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
3048
3048
DISPATCH ();
3049
3049
}
3050
3050
3051
- TARGET (WITH_CLEANUP_START ) {
3052
- /* At the top of the stack are 1 or 6 values indicating
3053
- how/why we entered the finally clause:
3054
- - TOP = None
3055
- - TOP = the return address (integer)
3056
- - (TOP, SECOND, THIRD) = exc_info()
3057
- (FOURTH, FITH, SIXTH) = previous exception for EXCEPT_HANDLER
3058
- Below them is EXIT, the context.__exit__ bound method.
3059
- In the last case, we must call
3060
- EXIT(TOP, SECOND, THIRD)
3061
- otherwise we must call
3062
- EXIT(None, None, None)
3063
-
3064
- In the first two cases, we remove EXIT from the
3065
- stack, leaving TOP. In the
3066
- last case, we shift the bottom 3 values of the
3067
- stack down, and replace the empty spot with NULL.
3068
-
3069
- In the last case we push TOP on the stack, otherwise we push
3070
- None on the stack. Finally we push the result of the call.
3071
- */
3072
- PyObject * stack [3 ];
3073
- PyObject * exit_func ;
3074
- PyObject * exc , * val , * tb , * res ;
3075
-
3076
- val = tb = Py_None ;
3077
- exc = TOP ();
3078
- if (exc == NULL || PyLong_CheckExact (exc )) {
3079
- STACKADJ (-1 );
3080
- exit_func = TOP ();
3081
- SET_TOP (exc );
3082
- exc = Py_None ;
3083
- }
3084
- else {
3085
- assert (PyExceptionClass_Check (exc ));
3086
- PyObject * tp2 , * exc2 , * tb2 ;
3087
- PyTryBlock * block ;
3088
- val = SECOND ();
3089
- tb = THIRD ();
3090
- tp2 = FOURTH ();
3091
- exc2 = PEEK (5 );
3092
- tb2 = PEEK (6 );
3093
- exit_func = PEEK (7 );
3094
- SET_VALUE (7 , tb2 );
3095
- SET_VALUE (6 , exc2 );
3096
- SET_VALUE (5 , tp2 );
3097
- /* UNWIND_EXCEPT_HANDLER will pop this off. */
3098
- SET_FOURTH (NULL );
3099
- /* We just shifted the stack down, so we have
3100
- to tell the except handler block that the
3101
- values are lower than it expects. */
3102
- assert (f -> f_iblock > 0 );
3103
- block = & f -> f_blockstack [f -> f_iblock - 1 ];
3104
- assert (block -> b_type == EXCEPT_HANDLER );
3105
- assert (block -> b_level > 0 );
3106
- block -> b_level -- ;
3107
- }
3108
-
3109
- stack [0 ] = exc ;
3110
- stack [1 ] = val ;
3111
- stack [2 ] = tb ;
3112
- res = _PyObject_FastCall (exit_func , stack , 3 );
3113
- Py_DECREF (exit_func );
3114
- if (res == NULL )
3115
- goto error ;
3116
-
3117
- Py_INCREF (exc ); /* Duplicating the exception on the stack */
3118
- PUSH (exc );
3119
- PUSH (res );
3120
- PREDICT (WITH_CLEANUP_FINISH );
3121
- DISPATCH ();
3122
- }
3123
-
3124
- PREDICTED (WITH_CLEANUP_FINISH );
3125
- TARGET (WITH_CLEANUP_FINISH ) {
3126
- /* TOP = the result of calling the context.__exit__ bound method
3127
- SECOND = either None or exception type
3128
-
3129
- If SECOND is None below is NULL or the return address,
3130
- otherwise below are 7 values representing an exception.
3131
- */
3132
- PyObject * res = POP ();
3133
- PyObject * exc = POP ();
3134
- int err ;
3135
-
3136
- if (exc != Py_None )
3137
- err = PyObject_IsTrue (res );
3138
- else
3139
- err = 0 ;
3140
-
3141
- Py_DECREF (res );
3142
- Py_DECREF (exc );
3143
-
3144
- if (err < 0 )
3145
- goto error ;
3146
- else if (err > 0 ) {
3147
- /* There was an exception and a True return.
3148
- * We must manually unwind the EXCEPT_HANDLER block
3149
- * which was created when the exception was caught,
3150
- * otherwise the stack will be in an inconsisten state.
3151
- */
3152
- PyTryBlock * b = PyFrame_BlockPop (f );
3153
- assert (b -> b_type == EXCEPT_HANDLER );
3154
- UNWIND_EXCEPT_HANDLER (b );
3155
- PUSH (NULL );
3156
- }
3157
- PREDICT (END_FINALLY );
3158
- DISPATCH ();
3159
- }
3160
-
3161
3051
TARGET (LOAD_METHOD ) {
3162
3052
/* Designed to work in tamdem with CALL_METHOD. */
3163
3053
PyObject * name = GETITEM (names , oparg );
0 commit comments