@@ -95,7 +95,7 @@ static PyObject * special_lookup(PyThreadState *, PyObject *, _Py_Identifier *);
95
95
static int check_args_iterable (PyThreadState * , PyObject * func , PyObject * vararg );
96
96
static void format_kwargs_error (PyThreadState * , PyObject * func , PyObject * kwargs );
97
97
static void format_awaitable_error (PyThreadState * , PyTypeObject * , int , int );
98
- static PyTryBlock get_exception_handler (PyCodeObject * , int );
98
+ static int get_exception_handler (PyCodeObject * , int , int * , int * , int * );
99
99
100
100
#define NAME_ERROR_MSG \
101
101
"name '%.200s' is not defined"
@@ -4461,21 +4461,20 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
4461
4461
exception_unwind :
4462
4462
f -> f_state = FRAME_UNWINDING ;
4463
4463
/* We can't use f->f_lasti here, as RERAISE may have set it */
4464
- int lasti = INSTR_OFFSET ()- 1 ;
4465
- PyTryBlock from_table = get_exception_handler ( co , lasti ) ;
4466
- if (from_table . b_handler < 0 ) {
4464
+ int offset = INSTR_OFFSET ()- 1 ;
4465
+ int level , handler , lasti ;
4466
+ if (get_exception_handler ( co , offset , & level , & handler , & lasti ) == 0 ) {
4467
4467
// No handlers, so exit.
4468
4468
break ;
4469
4469
}
4470
4470
4471
- assert (STACK_LEVEL () >= from_table . b_level );
4472
- while (STACK_LEVEL () > from_table . b_level ) {
4471
+ assert (STACK_LEVEL () >= level );
4472
+ while (STACK_LEVEL () > level ) {
4473
4473
PyObject * v = POP ();
4474
4474
Py_XDECREF (v );
4475
4475
}
4476
4476
PyObject * exc , * val , * tb ;
4477
- int handler = from_table .b_handler ;
4478
- if (from_table .b_type ) {
4477
+ if (lasti ) {
4479
4478
PyObject * lasti = PyLong_FromLong (f -> f_lasti );
4480
4479
if (lasti == NULL ) {
4481
4480
goto exception_unwind ;
@@ -4811,21 +4810,11 @@ parse_range(unsigned char *p, int *start, int*end)
4811
4810
return p ;
4812
4811
}
4813
4812
4814
- static inline void
4815
- parse_block (unsigned char * p , PyTryBlock * block ) {
4816
- int depth_and_lasti ;
4817
- p = parse_varint (p , & block -> b_handler );
4818
- p = parse_varint (p , & depth_and_lasti );
4819
- block -> b_level = depth_and_lasti >> 1 ;
4820
- block -> b_type = depth_and_lasti & 1 ;
4821
- }
4822
-
4823
4813
#define MAX_LINEAR_SEARCH 40
4824
4814
4825
- static PyTryBlock
4826
- get_exception_handler (PyCodeObject * code , int index )
4815
+ static int
4816
+ get_exception_handler (PyCodeObject * code , int index , int * level , int * handler , int * lasti )
4827
4817
{
4828
- PyTryBlock res ;
4829
4818
unsigned char * start = (unsigned char * )PyBytes_AS_STRING (code -> co_exceptiontable );
4830
4819
unsigned char * end = start + PyBytes_GET_SIZE (code -> co_exceptiontable );
4831
4820
/* Invariants:
@@ -4837,8 +4826,7 @@ get_exception_handler(PyCodeObject *code, int index)
4837
4826
int offset ;
4838
4827
parse_varint (start , & offset );
4839
4828
if (offset > index ) {
4840
- res .b_handler = -1 ;
4841
- return res ;
4829
+ return 0 ;
4842
4830
}
4843
4831
do {
4844
4832
unsigned char * mid = start + ((end - start )>>1 );
@@ -4862,13 +4850,16 @@ get_exception_handler(PyCodeObject *code, int index)
4862
4850
}
4863
4851
scan = parse_varint (scan , & size );
4864
4852
if (start_offset + size > index ) {
4865
- parse_block (scan , & res );
4866
- return res ;
4853
+ scan = parse_varint (scan , handler );
4854
+ int depth_and_lasti ;
4855
+ parse_varint (scan , & depth_and_lasti );
4856
+ * level = depth_and_lasti >> 1 ;
4857
+ * lasti = depth_and_lasti & 1 ;
4858
+ return 1 ;
4867
4859
}
4868
4860
scan = skip_to_next_entry (scan , end );
4869
4861
}
4870
- res .b_handler = -1 ;
4871
- return res ;
4862
+ return 0 ;
4872
4863
}
4873
4864
4874
4865
PyFrameObject *
0 commit comments