@@ -1916,7 +1916,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
1916
1916
1917
1917
TARGET (BEGIN_FINALLY ) {
1918
1918
/* Push NULL onto the stack for using it in END_FINALLY,
1919
- POP_FINALLY, WITH_CLEANUP_START and WITH_CLEANUP_FINISH .
1919
+ POP_FINALLY.
1920
1920
*/
1921
1921
PUSH (NULL );
1922
1922
FAST_DISPATCH ();
@@ -2994,116 +2994,6 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
2994
2994
DISPATCH ();
2995
2995
}
2996
2996
2997
- TARGET (WITH_CLEANUP_START ) {
2998
- /* At the top of the stack are 1 or 6 values indicating
2999
- how/why we entered the finally clause:
3000
- - TOP = NULL
3001
- - (TOP, SECOND, THIRD) = exc_info()
3002
- (FOURTH, FITH, SIXTH) = previous exception for EXCEPT_HANDLER
3003
- Below them is EXIT, the context.__exit__ or context.__aexit__
3004
- bound method.
3005
- In the first case, we must call
3006
- EXIT(None, None, None)
3007
- otherwise we must call
3008
- EXIT(TOP, SECOND, THIRD)
3009
-
3010
- In the first case, we remove EXIT from the
3011
- stack, leaving TOP, and push TOP on the stack.
3012
- Otherwise we shift the bottom 3 values of the
3013
- stack down, replace the empty spot with NULL, and push
3014
- None on the stack.
3015
-
3016
- Finally we push the result of the call.
3017
- */
3018
- PyObject * stack [3 ];
3019
- PyObject * exit_func ;
3020
- PyObject * exc , * val , * tb , * res ;
3021
-
3022
- val = tb = Py_None ;
3023
- exc = TOP ();
3024
- if (exc == NULL ) {
3025
- STACKADJ (-1 );
3026
- exit_func = TOP ();
3027
- SET_TOP (exc );
3028
- exc = Py_None ;
3029
- }
3030
- else {
3031
- assert (PyExceptionClass_Check (exc ));
3032
- PyObject * tp2 , * exc2 , * tb2 ;
3033
- PyTryBlock * block ;
3034
- val = SECOND ();
3035
- tb = THIRD ();
3036
- tp2 = FOURTH ();
3037
- exc2 = PEEK (5 );
3038
- tb2 = PEEK (6 );
3039
- exit_func = PEEK (7 );
3040
- SET_VALUE (7 , tb2 );
3041
- SET_VALUE (6 , exc2 );
3042
- SET_VALUE (5 , tp2 );
3043
- /* UNWIND_EXCEPT_HANDLER will pop this off. */
3044
- SET_FOURTH (NULL );
3045
- /* We just shifted the stack down, so we have
3046
- to tell the except handler block that the
3047
- values are lower than it expects. */
3048
- assert (f -> f_iblock > 0 );
3049
- block = & f -> f_blockstack [f -> f_iblock - 1 ];
3050
- assert (block -> b_type == EXCEPT_HANDLER );
3051
- assert (block -> b_level > 0 );
3052
- block -> b_level -- ;
3053
- }
3054
-
3055
- stack [0 ] = exc ;
3056
- stack [1 ] = val ;
3057
- stack [2 ] = tb ;
3058
- res = _PyObject_FastCall (exit_func , stack , 3 );
3059
- Py_DECREF (exit_func );
3060
- if (res == NULL )
3061
- goto error ;
3062
-
3063
- Py_INCREF (exc ); /* Duplicating the exception on the stack */
3064
- PUSH (exc );
3065
- PUSH (res );
3066
- PREDICT (WITH_CLEANUP_FINISH );
3067
- DISPATCH ();
3068
- }
3069
-
3070
- PREDICTED (WITH_CLEANUP_FINISH );
3071
- TARGET (WITH_CLEANUP_FINISH ) {
3072
- /* TOP = the result of calling the context.__exit__ bound method
3073
- SECOND = either None or exception type
3074
-
3075
- If SECOND is None below is NULL or the return address,
3076
- otherwise below are 7 values representing an exception.
3077
- */
3078
- PyObject * res = POP ();
3079
- PyObject * exc = POP ();
3080
- int err ;
3081
-
3082
- if (exc != Py_None )
3083
- err = PyObject_IsTrue (res );
3084
- else
3085
- err = 0 ;
3086
-
3087
- Py_DECREF (res );
3088
- Py_DECREF (exc );
3089
-
3090
- if (err < 0 )
3091
- goto error ;
3092
- else if (err > 0 ) {
3093
- /* There was an exception and a True return.
3094
- * We must manually unwind the EXCEPT_HANDLER block
3095
- * which was created when the exception was caught,
3096
- * otherwise the stack will be in an inconsisten state.
3097
- */
3098
- PyTryBlock * b = PyFrame_BlockPop (f );
3099
- assert (b -> b_type == EXCEPT_HANDLER );
3100
- UNWIND_EXCEPT_HANDLER (b );
3101
- PUSH (NULL );
3102
- }
3103
- PREDICT (END_FINALLY );
3104
- DISPATCH ();
3105
- }
3106
-
3107
2997
TARGET (LOAD_METHOD ) {
3108
2998
/* Designed to work in tamdem with CALL_METHOD. */
3109
2999
PyObject * name = GETITEM (names , oparg );
0 commit comments