| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c93f791 commit 0efcab0
22 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -563,7 +563,7 @@ _PyCode_GetTLBCFast(PyThreadState *tstate, PyCodeObject *co) | |||
| 563 | 563 | ||
| 564 | 564 | // Return a pointer to the thread-local bytecode for the current thread, | |
| 565 | 565 | // creating it if necessary. | |
| 566 | - extern _Py_CODEUNIT *_PyCode_GetTLBC(PyCodeObject *co); | ||
| 566 | + PyAPI_FUNC(_Py_CODEUNIT *) _PyCode_GetTLBC(PyCodeObject *co); | ||
| 567 | 567 | ||
| 568 | 568 | // Reserve an index for the current thread into thread-local bytecode | |
| 569 | 569 | // arrays | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -67,8 +67,8 @@ _Py_call_instrumentation_exc2(PyThreadState *tstate, int event, | |||
| 67 | 67 | extern int | |
| 68 | 68 | _Py_Instrumentation_GetLine(PyCodeObject *code, int index); | |
| 69 | 69 | ||
| 70 | - extern PyObject _PyInstrumentation_MISSING; | ||
| 71 | - extern PyObject _PyInstrumentation_DISABLE; | ||
| 70 | + PyAPI_DATA(PyObject) _PyInstrumentation_MISSING; | ||
| 71 | + PyAPI_DATA(PyObject) _PyInstrumentation_DISABLE; | ||
| 72 | 72 | ||
| 73 | 73 | ||
| 74 | 74 | /* Total tool ids available */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -279,7 +279,7 @@ _PyThreadState_GetFrame(PyThreadState *tstate) | |||
| 279 | 279 | ||
| 280 | 280 | /* For use by _PyFrame_GetFrameObject | |
| 281 | 281 | Do not call directly. */ | |
| 282 | - PyFrameObject * | ||
| 282 | + PyAPI_FUNC(PyFrameObject *) | ||
| 283 | 283 | _PyFrame_MakeAndSetFrameObject(_PyInterpreterFrame *frame); | |
| 284 | 284 | ||
| 285 | 285 | /* Gets the PyFrameObject for this frame, lazily | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,12 +17,12 @@ PyAPI_FUNC(PyObject) *_PyList_SliceSubscript(PyObject*, PyObject*); | |||
| 17 | 17 | extern void _PyList_DebugMallocStats(FILE *out); | |
| 18 | 18 | // _PyList_GetItemRef should be used only when the object is known as a list | |
| 19 | 19 | // because it doesn't raise TypeError when the object is not a list, whereas PyList_GetItemRef does. | |
| 20 | - extern PyObject* _PyList_GetItemRef(PyListObject *, Py_ssize_t i); | ||
| 20 | + PyAPI_FUNC(PyObject *) _PyList_GetItemRef(PyListObject *, Py_ssize_t i); | ||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | 23 | #ifdef Py_GIL_DISABLED | |
| 24 | 24 | // Returns -1 in case of races with other threads. | |
| 25 | - extern int _PyList_GetItemRefNoLock(PyListObject *, Py_ssize_t, _PyStackRef *); | ||
| 25 | + PyAPI_FUNC(int) _PyList_GetItemRefNoLock(PyListObject *, Py_ssize_t, _PyStackRef *); | ||
| 26 | 26 | #endif | |
| 27 | 27 | ||
| 28 | 28 | #define _PyList_ITEMS(op) _Py_RVALUE(_PyList_CAST(op)->ob_item) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,8 +11,8 @@ extern "C" { | |||
| 11 | 11 | ||
| 12 | 12 | /* Error handling definitions */ | |
| 13 | 13 | ||
| 14 | - extern _PyErr_StackItem* _PyErr_GetTopmostException(PyThreadState *tstate); | ||
| 15 | - extern PyObject* _PyErr_GetHandledException(PyThreadState *); | ||
| 14 | + PyAPI_FUNC(_PyErr_StackItem*) _PyErr_GetTopmostException(PyThreadState *tstate); | ||
| 15 | + PyAPI_FUNC(PyObject*) _PyErr_GetHandledException(PyThreadState *); | ||
| 16 | 16 | extern void _PyErr_SetHandledException(PyThreadState *, PyObject *); | |
| 17 | 17 | extern void _PyErr_GetExcInfo(PyThreadState *, PyObject **, PyObject **, PyObject **); | |
| 18 | 18 | ||
@@ -108,7 +108,7 @@ extern void _PyErr_Restore( | |||
| 108 | 108 | PyObject *value, | |
| 109 | 109 | PyObject *traceback); | |
| 110 | 110 | ||
| 111 | - extern void _PyErr_SetObject( | ||
| 111 | + PyAPI_FUNC(void) _PyErr_SetObject( | ||
| 112 | 112 | PyThreadState *tstate, | |
| 113 | 113 | PyObject *type, | |
| 114 | 114 | PyObject *value); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2857,6 +2857,24 @@ def func(): | |||
| 2857 | 2857 | names = ["func", "outer", "outer", "inner", "inner", "outer", "inner"] | |
| 2858 | 2858 | self.do_test(func, names) | |
| 2859 | 2859 | ||
| 2860 | + def test_replaced_interpreter(self): | ||
| 2861 | + def inner(): | ||
| 2862 | + yield 'abc' | ||
| 2863 | + def outer(): | ||
| 2864 | + yield from inner() | ||
| 2865 | + def func(): | ||
| 2866 | + list(outer()) | ||
| 2867 | + _testinternalcapi.set_eval_frame_interp() | ||
| 2868 | + try: | ||
| 2869 | + func() | ||
| 2870 | + finally: | ||
| 2871 | + _testinternalcapi.set_eval_frame_default() | ||
| 2872 | + | ||
| 2873 | + stats = _testinternalcapi.get_eval_frame_stats() | ||
| 2874 | + | ||
| 2875 | + self.assertEqual(stats["resumes"], 5) | ||
| 2876 | + self.assertEqual(stats["loads"], 5) | ||
| 2877 | + | ||
| 2860 | 2878 | ||
| 2861 | 2879 | @unittest.skipUnless(support.Py_GIL_DISABLED, 'need Py_GIL_DISABLED') | |
| 2862 | 2880 | class TestPyThreadId(unittest.TestCase): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2150,7 +2150,7 @@ Objects/mimalloc/page.o: $(srcdir)/Objects/mimalloc/page-queue.c | |||
| 2150 | 2150 | regen-cases: \ | |
| 2151 | 2151 | regen-opcode-ids regen-opcode-targets regen-uop-ids regen-opcode-metadata-py \ | |
| 2152 | 2152 | regen-generated-cases regen-executor-cases regen-optimizer-cases \ | |
| 2153 | - regen-opcode-metadata regen-uop-metadata | ||
| 2153 | + regen-opcode-metadata regen-uop-metadata regen-test-cases regen-test-opcode-targets | ||
| 2154 | 2154 | ||
| 2155 | 2155 | .PHONY: regen-opcode-ids | |
| 2156 | 2156 | regen-opcode-ids: | |
@@ -2182,6 +2182,20 @@ regen-generated-cases: | |||
| 2182 | 2182 | -o $(srcdir)/Python/generated_cases.c.h.new $(srcdir)/Python/bytecodes.c | |
| 2183 | 2183 | $(UPDATE_FILE) $(srcdir)/Python/generated_cases.c.h $(srcdir)/Python/generated_cases.c.h.new | |
| 2184 | 2184 | ||
| 2185 | + .PHONY: regen-test-cases | ||
| 2186 | + regen-test-cases: | ||
| 2187 | + $(PYTHON_FOR_REGEN) $(srcdir)/Tools/cases_generator/tier1_generator.py \ | ||
| 2188 | + -o $(srcdir)/Modules/_testinternalcapi/test_cases.c.h.new $(srcdir)/Python/bytecodes.c \ | ||
| 2189 | + $(srcdir)/Modules/_testinternalcapi/testbytecodes.c | ||
| 2190 | + $(UPDATE_FILE) $(srcdir)/Modules/_testinternalcapi/test_cases.c.h $(srcdir)/Modules/_testinternalcapi/test_cases.c.h.new | ||
| 2191 | + | ||
| 2192 | + .PHONY: regen-test-opcode-targets | ||
| 2193 | + regen-test-opcode-targets: | ||
| 2194 | + $(PYTHON_FOR_REGEN) $(srcdir)/Tools/cases_generator/target_generator.py \ | ||
| 2195 | + -o $(srcdir)/Modules/_testinternalcapi/test_targets.h.new $(srcdir)/Python/bytecodes.c \ | ||
| 2196 | + $(srcdir)/Modules/_testinternalcapi/testbytecodes.c | ||
| 2197 | + $(UPDATE_FILE) $(srcdir)/Modules/_testinternalcapi/test_targets.h $(srcdir)/Modules/_testinternalcapi/test_targets.h.new | ||
| 2198 | + | ||
| 2185 | 2199 | .PHONY: regen-executor-cases | |
| 2186 | 2200 | regen-executor-cases: | |
| 2187 | 2201 | $(PYTHON_FOR_REGEN) $(srcdir)/Tools/cases_generator/tier2_generator.py \ | |
@@ -3428,7 +3442,7 @@ MODULE__SOCKET_DEPS=$(srcdir)/Modules/socketmodule.h $(srcdir)/Modules/addrinfo. | |||
| 3428 | 3442 | MODULE__SSL_DEPS=$(srcdir)/Modules/_ssl.h $(srcdir)/Modules/_ssl/cert.c $(srcdir)/Modules/_ssl/debughelpers.c $(srcdir)/Modules/_ssl/misc.c $(srcdir)/Modules/_ssl_data_111.h $(srcdir)/Modules/_ssl_data_300.h $(srcdir)/Modules/socketmodule.h | |
| 3429 | 3443 | MODULE__TESTCAPI_DEPS=$(srcdir)/Modules/_testcapi/parts.h $(srcdir)/Modules/_testcapi/util.h | |
| 3430 | 3444 | MODULE__TESTLIMITEDCAPI_DEPS=$(srcdir)/Modules/_testlimitedcapi/testcapi_long.h $(srcdir)/Modules/_testlimitedcapi/parts.h $(srcdir)/Modules/_testlimitedcapi/util.h | |
| 3431 | - MODULE__TESTINTERNALCAPI_DEPS=$(srcdir)/Modules/_testinternalcapi/parts.h | ||
| 3445 | + MODULE__TESTINTERNALCAPI_DEPS=$(srcdir)/Modules/_testinternalcapi/parts.h $(srcdir)/Python/ceval.h $(srcdir)/Modules/_testinternalcapi/test_targets.h $(srcdir)/Modules/_testinternalcapi/test_cases.c.h | ||
| 3432 | 3446 | MODULE__SQLITE3_DEPS=$(srcdir)/Modules/_sqlite/connection.h $(srcdir)/Modules/_sqlite/cursor.h $(srcdir)/Modules/_sqlite/microprotocols.h $(srcdir)/Modules/_sqlite/module.h $(srcdir)/Modules/_sqlite/prepare_protocol.h $(srcdir)/Modules/_sqlite/row.h $(srcdir)/Modules/_sqlite/util.h | |
| 3433 | 3447 | MODULE__ZSTD_DEPS=$(srcdir)/Modules/_zstd/_zstdmodule.h $(srcdir)/Modules/_zstd/buffer.h $(srcdir)/Modules/_zstd/zstddict.h | |
| 3434 | 3448 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -174,7 +174,7 @@ | |||
| 174 | 174 | @MODULE_XXSUBTYPE_TRUE@xxsubtype xxsubtype.c | |
| 175 | 175 | @MODULE__XXTESTFUZZ_TRUE@_xxtestfuzz _xxtestfuzz/_xxtestfuzz.c _xxtestfuzz/fuzzer.c | |
| 176 | 176 | @MODULE__TESTBUFFER_TRUE@_testbuffer _testbuffer.c | |
| 177 | - @MODULE__TESTINTERNALCAPI_TRUE@_testinternalcapi _testinternalcapi.c _testinternalcapi/test_lock.c _testinternalcapi/pytime.c _testinternalcapi/set.c _testinternalcapi/test_critical_sections.c _testinternalcapi/complex.c | ||
| 177 | + @MODULE__TESTINTERNALCAPI_TRUE@_testinternalcapi _testinternalcapi.c _testinternalcapi/test_lock.c _testinternalcapi/pytime.c _testinternalcapi/set.c _testinternalcapi/test_critical_sections.c _testinternalcapi/complex.c _testinternalcapi/interpreter.c | ||
| 178 | 178 | @MODULE__TESTCAPI_TRUE@_testcapi _testcapimodule.c _testcapi/vectorcall.c _testcapi/heaptype.c _testcapi/abstract.c _testcapi/unicode.c _testcapi/dict.c _testcapi/set.c _testcapi/list.c _testcapi/tuple.c _testcapi/getargs.c _testcapi/datetime.c _testcapi/docstring.c _testcapi/mem.c _testcapi/watchers.c _testcapi/long.c _testcapi/float.c _testcapi/complex.c _testcapi/numbers.c _testcapi/structmember.c _testcapi/exceptions.c _testcapi/code.c _testcapi/buffer.c _testcapi/pyatomic.c _testcapi/run.c _testcapi/file.c _testcapi/codec.c _testcapi/immortal.c _testcapi/gc.c _testcapi/hash.c _testcapi/time.c _testcapi/bytes.c _testcapi/object.c _testcapi/modsupport.c _testcapi/monitoring.c _testcapi/config.c _testcapi/import.c _testcapi/frame.c _testcapi/type.c _testcapi/function.c _testcapi/module.c | |
| 179 | 179 | @MODULE__TESTLIMITEDCAPI_TRUE@_testlimitedcapi _testlimitedcapi.c _testlimitedcapi/abstract.c _testlimitedcapi/bytearray.c _testlimitedcapi/bytes.c _testlimitedcapi/codec.c _testlimitedcapi/complex.c _testlimitedcapi/dict.c _testlimitedcapi/eval.c _testlimitedcapi/float.c _testlimitedcapi/heaptype_relative.c _testlimitedcapi/import.c _testlimitedcapi/list.c _testlimitedcapi/long.c _testlimitedcapi/object.c _testlimitedcapi/pyos.c _testlimitedcapi/set.c _testlimitedcapi/sys.c _testlimitedcapi/tuple.c _testlimitedcapi/unicode.c _testlimitedcapi/vectorcall_limited.c _testlimitedcapi/version.c _testlimitedcapi/file.c | |
| 180 | 180 | @MODULE__TESTCLINIC_TRUE@_testclinic _testclinic.c | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -693,6 +693,43 @@ set_eval_frame_record(PyObject *self, PyObject *list) | |||
| 693 | 693 | Py_RETURN_NONE; | |
| 694 | 694 | } | |
| 695 | 695 | ||
| 696 | + // Defined in interpreter.c | ||
| 697 | + extern PyObject* | ||
| 698 | + Test_EvalFrame(PyThreadState *tstate, _PyInterpreterFrame *frame, int throwflag); | ||
| 699 | + extern int Test_EvalFrame_Resumes, Test_EvalFrame_Loads; | ||
| 700 | + | ||
| 701 | + static PyObject * | ||
| 702 | + get_eval_frame_stats(PyObject *self, PyObject *Py_UNUSED(args)) | ||
| 703 | + { | ||
| 704 | + PyObject *res = PyDict_New(); | ||
| 705 | + if (res == NULL) { | ||
| 706 | + return NULL; | ||
| 707 | + } | ||
| 708 | + PyObject *resumes = PyLong_FromLong(Test_EvalFrame_Resumes); | ||
| 709 | + if (resumes == NULL || PyDict_SetItemString(res, "resumes", resumes) < 0) { | ||
| 710 | + Py_XDECREF(resumes); | ||
| 711 | + Py_DECREF(res); | ||
| 712 | + return NULL; | ||
| 713 | + } | ||
| 714 | + Py_DECREF(resumes); | ||
| 715 | + PyObject *loads = PyLong_FromLong(Test_EvalFrame_Loads); | ||
| 716 | + if (loads == NULL || PyDict_SetItemString(res, "loads", loads) < 0) { | ||
| 717 | + Py_XDECREF(loads); | ||
| 718 | + Py_DECREF(res); | ||
| 719 | + return NULL; | ||
| 720 | + } | ||
| 721 | + Py_DECREF(loads); | ||
| 722 | + Test_EvalFrame_Resumes = Test_EvalFrame_Loads = 0; | ||
| 723 | + return res; | ||
| 724 | + } | ||
| 725 | + | ||
| 726 | + static PyObject * | ||
| 727 | + set_eval_frame_interp(PyObject *self, PyObject *Py_UNUSED(args)) | ||
| 728 | + { | ||
| 729 | + _PyInterpreterState_SetEvalFrameFunc(_PyInterpreterState_GET(), Test_EvalFrame); | ||
| 730 | + Py_RETURN_NONE; | ||
| 731 | + } | ||
| 732 | + | ||
| 696 | 733 | /*[clinic input] | |
| 697 | 734 | ||
| 698 | 735 | _testinternalcapi.compiler_cleandoc -> object | |
@@ -2531,6 +2568,7 @@ test_threadstate_set_stack_protection(PyObject *self, PyObject *Py_UNUSED(args)) | |||
| 2531 | 2568 | ||
| 2532 | 2569 | static PyMethodDef module_functions[] = { | |
| 2533 | 2570 | {"get_configs", get_configs, METH_NOARGS}, | |
| 2571 | + {"get_eval_frame_stats", get_eval_frame_stats, METH_NOARGS, NULL}, | ||
| 2534 | 2572 | {"get_recursion_depth", get_recursion_depth, METH_NOARGS}, | |
| 2535 | 2573 | {"get_c_recursion_remaining", get_c_recursion_remaining, METH_NOARGS}, | |
| 2536 | 2574 | {"get_stack_pointer", get_stack_pointer, METH_NOARGS}, | |
@@ -2547,6 +2585,7 @@ static PyMethodDef module_functions[] = { | |||
| 2547 | 2585 | {"EncodeLocaleEx", encode_locale_ex, METH_VARARGS}, | |
| 2548 | 2586 | {"DecodeLocaleEx", decode_locale_ex, METH_VARARGS}, | |
| 2549 | 2587 | {"set_eval_frame_default", set_eval_frame_default, METH_NOARGS, NULL}, | |
| 2588 | + {"set_eval_frame_interp", set_eval_frame_interp, METH_NOARGS, NULL}, | ||
| 2550 | 2589 | {"set_eval_frame_record", set_eval_frame_record, METH_O, NULL}, | |
| 2551 | 2590 | _TESTINTERNALCAPI_COMPILER_CLEANDOC_METHODDEF | |
| 2552 | 2591 | _TESTINTERNALCAPI_NEW_INSTRUCTION_SEQUENCE_METHODDEF | |
| Back | FazBrowse Home | New Git URL |
0 commit comments