From 67a8f6f75634bb81c7d891a1e07c3a38ac73dee8 Mon Sep 17 00:00:00 2001 From: Manjusaka Date: Thu, 27 Jun 2024 18:05:13 +0800 Subject: [PATCH 1/5] Fix build failure when the developer use `--enable-pystats` arguments in configuration command after #118450 Signed-off-by: Manjusaka --- .../Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst | 1 + Python/specialize.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst diff --git a/Misc/NEWS.d/next/Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst b/Misc/NEWS.d/next/Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst new file mode 100644 index 00000000000000..7a041666b1d7d3 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst @@ -0,0 +1 @@ +Fix build failure when the developer use `--enable-pystats` arguments in configuration command after #118450 diff --git a/Python/specialize.c b/Python/specialize.c index dc0e319880b976..5e339dfee7a9ad 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -2364,7 +2364,8 @@ _Py_Specialize_ForIter(_PyStackRef iter, _Py_CODEUNIT *instr, int oparg) assert(ENABLE_SPECIALIZATION); assert(_PyOpcode_Caches[FOR_ITER] == INLINE_CACHE_ENTRIES_FOR_ITER); _PyForIterCache *cache = (_PyForIterCache *)(instr + 1); - PyTypeObject *tp = Py_TYPE(PyStackRef_AsPyObjectBorrow(iter)); + PyObject *iterObject = PyStackRef_AsPyObjectBorrow(iter); + PyTypeObject *tp = Py_TYPE(iterObject); if (tp == &PyListIter_Type) { instr->op.code = FOR_ITER_LIST; goto success; @@ -2389,7 +2390,7 @@ _Py_Specialize_ForIter(_PyStackRef iter, _Py_CODEUNIT *instr, int oparg) goto success; } SPECIALIZATION_FAIL(FOR_ITER, - _PySpecialization_ClassifyIterator(iter)); + _PySpecialization_ClassifyIterator(iterObject)); failure: STAT_INC(FOR_ITER, failure); instr->op.code = FOR_ITER; From 8765ccc0affc10f44795c409a31d036537c8b7b2 Mon Sep 17 00:00:00 2001 From: Manjusaka Date: Thu, 27 Jun 2024 18:10:28 +0800 Subject: [PATCH 2/5] fix docs lint Signed-off-by: Manjusaka --- .../next/Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst b/Misc/NEWS.d/next/Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst index 7a041666b1d7d3..eeb5e5bc02caa4 100644 --- a/Misc/NEWS.d/next/Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst +++ b/Misc/NEWS.d/next/Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst @@ -1 +1,2 @@ -Fix build failure when the developer use `--enable-pystats` arguments in configuration command after #118450 +Fix build failure when the developer use `--enable-pystats` arguments in +configuration command after #118450 From ac7a385392e1728c85c438ba9e057ada84a7e503 Mon Sep 17 00:00:00 2001 From: Manjusaka Date: Thu, 27 Jun 2024 18:12:54 +0800 Subject: [PATCH 3/5] Fix docs lint error --- .../next/Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst b/Misc/NEWS.d/next/Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst index eeb5e5bc02caa4..652c65a6841a42 100644 --- a/Misc/NEWS.d/next/Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst +++ b/Misc/NEWS.d/next/Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst @@ -1,2 +1,2 @@ -Fix build failure when the developer use `--enable-pystats` arguments in +Fix build failure when the developer use ``--enable-pystats`` arguments in configuration command after #118450 From 1d408a665439a34fcd30206facf36174c287cfdb Mon Sep 17 00:00:00 2001 From: Manjusaka Date: Thu, 27 Jun 2024 18:16:33 +0800 Subject: [PATCH 4/5] Fix docs lint error --- .../next/Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Misc/NEWS.d/next/Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst b/Misc/NEWS.d/next/Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst index 652c65a6841a42..7657672ba880c8 100644 --- a/Misc/NEWS.d/next/Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst +++ b/Misc/NEWS.d/next/Build/2024-06-27-18-03-20.gh-issue-121082.w3AfRx.rst @@ -1,2 +1 @@ -Fix build failure when the developer use ``--enable-pystats`` arguments in -configuration command after #118450 +Fix build failure when the developer use ``--enable-pystats`` arguments in configuration command after #118450. From febd2577085eb4b13eac5e619356c1885e08c028 Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Thu, 27 Jun 2024 19:01:16 +0800 Subject: [PATCH 5/5] Apply suggestions from code review --- Python/specialize.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Python/specialize.c b/Python/specialize.c index 5e339dfee7a9ad..497feca06e4c7f 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -2364,8 +2364,8 @@ _Py_Specialize_ForIter(_PyStackRef iter, _Py_CODEUNIT *instr, int oparg) assert(ENABLE_SPECIALIZATION); assert(_PyOpcode_Caches[FOR_ITER] == INLINE_CACHE_ENTRIES_FOR_ITER); _PyForIterCache *cache = (_PyForIterCache *)(instr + 1); - PyObject *iterObject = PyStackRef_AsPyObjectBorrow(iter); - PyTypeObject *tp = Py_TYPE(iterObject); + PyObject *iter_o = PyStackRef_AsPyObjectBorrow(iter); + PyTypeObject *tp = Py_TYPE(iter_o); if (tp == &PyListIter_Type) { instr->op.code = FOR_ITER_LIST; goto success; @@ -2390,7 +2390,7 @@ _Py_Specialize_ForIter(_PyStackRef iter, _Py_CODEUNIT *instr, int oparg) goto success; } SPECIALIZATION_FAIL(FOR_ITER, - _PySpecialization_ClassifyIterator(iterObject)); + _PySpecialization_ClassifyIterator(iter_o)); failure: STAT_INC(FOR_ITER, failure); instr->op.code = FOR_ITER;