| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -715,7 +715,7 @@ def check_balanced(self, func, recorders): | |||
| 715 | 715 | self.assertIn(r0, ("raise", "reraise")) | |
| 716 | 716 | h0 = h[0] | |
| 717 | 717 | self.assertIn(h0, ("handled", "unwind")) | |
| 718 | - | ||
| 718 | + self.assertEqual(r[1], h[1]) | ||
| 719 | 719 | ||
| 720 | 720 | ||
| 721 | 721 | class StopiterationRecorder(ExceptionRecorder): | |
@@ -733,8 +733,8 @@ class UnwindRecorder(ExceptionRecorder): | |||
| 733 | 733 | ||
| 734 | 734 | event_type = E.PY_UNWIND | |
| 735 | 735 | ||
| 736 | - def __call__(self, *args): | ||
| 737 | - self.events.append(("unwind", None)) | ||
| 736 | + def __call__(self, code, offset, exc): | ||
| 737 | + self.events.append(("unwind", type(exc))) | ||
| 738 | 738 | ||
| 739 | 739 | class ExceptionHandledRecorder(ExceptionRecorder): | |
| 740 | 740 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + Add the exception as the third argument to ``PY_UNIND`` callbacks in | ||
| 2 | + ``sys.monitoring``. This makes the ``PY_UNWIND`` callback consistent with | ||
| 3 | + the other exception hanlding callbacks. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1987,7 +1987,7 @@ monitor_unwind(PyThreadState *tstate, | |||
| 1987 | 1987 | if (no_tools_for_event(tstate, frame, PY_MONITORING_EVENT_PY_UNWIND)) { | |
| 1988 | 1988 | return; | |
| 1989 | 1989 | } | |
| 1990 | - _Py_call_instrumentation_exc0(tstate, PY_MONITORING_EVENT_PY_UNWIND, frame, instr); | ||
| 1990 | + do_monitor_exc(tstate, frame, instr, PY_MONITORING_EVENT_PY_UNWIND); | ||
| 1991 | 1991 | } | |
| 1992 | 1992 | ||
| 1993 | 1993 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -64,6 +64,16 @@ sys_profile_func3( | |||
| 64 | 64 | return call_profile_func(self, args[2]); | |
| 65 | 65 | } | |
| 66 | 66 | ||
| 67 | + static PyObject * | ||
| 68 | + sys_profile_unwind( | ||
| 69 | + _PyLegacyEventHandler *self, PyObject *const *args, | ||
| 70 | + size_t nargsf, PyObject *kwnames | ||
| 71 | + ) { | ||
| 72 | + assert(kwnames == NULL); | ||
| 73 | + assert(PyVectorcall_NARGS(nargsf) == 3); | ||
| 74 | + return call_profile_func(self, Py_None); | ||
| 75 | + } | ||
| 76 | + | ||
| 67 | 77 | static PyObject * | |
| 68 | 78 | sys_profile_call_or_return( | |
| 69 | 79 | _PyLegacyEventHandler *self, PyObject *const *args, | |
@@ -152,6 +162,16 @@ sys_trace_func2( | |||
| 152 | 162 | return call_trace_func(self, Py_None); | |
| 153 | 163 | } | |
| 154 | 164 | ||
| 165 | + static PyObject * | ||
| 166 | + sys_trace_unwind( | ||
| 167 | + _PyLegacyEventHandler *self, PyObject *const *args, | ||
| 168 | + size_t nargsf, PyObject *kwnames | ||
| 169 | + ) { | ||
| 170 | + assert(kwnames == NULL); | ||
| 171 | + assert(PyVectorcall_NARGS(nargsf) == 3); | ||
| 172 | + return call_trace_func(self, Py_None); | ||
| 173 | + } | ||
| 174 | + | ||
| 155 | 175 | static PyObject * | |
| 156 | 176 | sys_trace_return( | |
| 157 | 177 | _PyLegacyEventHandler *self, PyObject *const *args, | |
@@ -362,7 +382,7 @@ _PyEval_SetProfile(PyThreadState *tstate, Py_tracefunc func, PyObject *arg) | |||
| 362 | 382 | return -1; | |
| 363 | 383 | } | |
| 364 | 384 | if (set_callbacks(PY_MONITORING_SYS_PROFILE_ID, | |
| 365 | - (vectorcallfunc)sys_profile_func2, PyTrace_RETURN, | ||
| 385 | + (vectorcallfunc)sys_profile_unwind, PyTrace_RETURN, | ||
| 366 | 386 | PY_MONITORING_EVENT_PY_UNWIND, -1)) { | |
| 367 | 387 | return -1; | |
| 368 | 388 | } | |
@@ -450,7 +470,7 @@ _PyEval_SetTrace(PyThreadState *tstate, Py_tracefunc func, PyObject *arg) | |||
| 450 | 470 | return -1; | |
| 451 | 471 | } | |
| 452 | 472 | if (set_callbacks(PY_MONITORING_SYS_TRACE_ID, | |
| 453 | - (vectorcallfunc)sys_trace_func2, PyTrace_RETURN, | ||
| 473 | + (vectorcallfunc)sys_trace_unwind, PyTrace_RETURN, | ||
| 454 | 474 | PY_MONITORING_EVENT_PY_UNWIND, -1)) { | |
| 455 | 475 | return -1; | |
| 456 | 476 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments