From 4b2ec1e815f2dcd85c4ced868ae46909abfcdad9 Mon Sep 17 00:00:00 2001 From: PuQing Date: Sun, 22 Jun 2025 18:48:29 +0800 Subject: [PATCH 1/5] fix instructions in __annotate__ have incorrect code positions --- Python/codegen.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Python/codegen.c b/Python/codegen.c index 27fe8e1957b2fe..317b2e881e6818 100644 --- a/Python/codegen.c +++ b/Python/codegen.c @@ -686,13 +686,14 @@ codegen_setup_annotations_scope(compiler *c, location loc, PyObject *value_with_fake_globals = PyLong_FromLong(_Py_ANNOTATE_FORMAT_VALUE_WITH_FAKE_GLOBALS); assert(!SYMTABLE_ENTRY(c)->ste_has_docstring); _Py_DECLARE_STR(format, ".format"); - ADDOP_I(c, loc, LOAD_FAST, 0); - ADDOP_LOAD_CONST(c, loc, value_with_fake_globals); - ADDOP_I(c, loc, COMPARE_OP, (Py_GT << 5) | compare_masks[Py_GT]); + + ADDOP_I(c, NO_LOCATION, LOAD_FAST, 0); + ADDOP_LOAD_CONST(c, NO_LOCATION, value_with_fake_globals); + ADDOP_I(c, NO_LOCATION, COMPARE_OP, (Py_GT << 5) | compare_masks[Py_GT]); NEW_JUMP_TARGET_LABEL(c, body); - ADDOP_JUMP(c, loc, POP_JUMP_IF_FALSE, body); - ADDOP_I(c, loc, LOAD_COMMON_CONSTANT, CONSTANT_NOTIMPLEMENTEDERROR); - ADDOP_I(c, loc, RAISE_VARARGS, 1); + ADDOP_JUMP(c, NO_LOCATION, POP_JUMP_IF_FALSE, body); + ADDOP_I(c, NO_LOCATION, LOAD_COMMON_CONSTANT, CONSTANT_NOTIMPLEMENTEDERROR); + ADDOP_I(c, NO_LOCATION, RAISE_VARARGS, 1); USE_LABEL(c, body); return SUCCESS; } @@ -751,7 +752,7 @@ codegen_deferred_annotations_body(compiler *c, location loc, assert(PyList_CheckExact(conditional_annotation_indices)); assert(annotations_len == PyList_Size(conditional_annotation_indices)); - ADDOP_I(c, loc, BUILD_MAP, 0); // stack now contains + ADDOP_I(c, NO_LOCATION, BUILD_MAP, 0); // stack now contains for (Py_ssize_t i = 0; i < annotations_len; i++) { PyObject *ptr = PyList_GET_ITEM(deferred_anno, i); From 35246e7432732370c403b2d206706c639243fdfd Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sun, 22 Jun 2025 10:47:28 +0000 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2025-06-22-10-47-27.gh-issue-135700.0qdtCl.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2025-06-22-10-47-27.gh-issue-135700.0qdtCl.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-06-22-10-47-27.gh-issue-135700.0qdtCl.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-06-22-10-47-27.gh-issue-135700.0qdtCl.rst new file mode 100644 index 00000000000000..6b1b9ddea2ab79 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-06-22-10-47-27.gh-issue-135700.0qdtCl.rst @@ -0,0 +1 @@ +Fix instructions in __annotate__ have incorrect code positions From 97bddb8db22404525eaab805fdedfd06b8e2842a Mon Sep 17 00:00:00 2001 From: PuQing Date: Sun, 22 Jun 2025 20:13:25 +0800 Subject: [PATCH 3/5] Update Misc/NEWS.d/next/Core_and_Builtins/2025-06-22-10-47-27.gh-issue-135700.0qdtCl.rst Co-authored-by: sobolevn --- .../2025-06-22-10-47-27.gh-issue-135700.0qdtCl.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-06-22-10-47-27.gh-issue-135700.0qdtCl.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-06-22-10-47-27.gh-issue-135700.0qdtCl.rst index 6b1b9ddea2ab79..dec0f3291c5125 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2025-06-22-10-47-27.gh-issue-135700.0qdtCl.rst +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-06-22-10-47-27.gh-issue-135700.0qdtCl.rst @@ -1 +1 @@ -Fix instructions in __annotate__ have incorrect code positions +Fix instructions positions in :attr:`~object.__annotate__`. From 4de616a9355df2eab9ecf934b10cd8a60f91b441 Mon Sep 17 00:00:00 2001 From: PuQing Date: Sun, 22 Jun 2025 23:08:09 +0800 Subject: [PATCH 4/5] add unit tests Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Co-authored-by: Frank Hoffmann <15r10nk@users.noreply.github.com> --- Lib/test/test_pdb.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index 6b74e21ad73d1a..e8bcc3e3beeabc 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -3816,6 +3816,31 @@ def bar(): self.assertIn('-> pass', lines) self.assertIn('(Pdb) 42', lines) + def test_issue135700(self): + """https://github.com/python/cpython/issues/135700""" + module_code = """\ + 22 + + class ClassVar: + pass + __dataclass_fields__: ClassVar + """ + with open("testmod.py", "w") as f: + f.write(module_code) + self.addCleanup(os_helper.unlink, "testmod.py") + + script = """ + import testmod + print(testmod.__annotations__) + """ + commands = """ + b testmod.py:1 + c + c + """ + result = self.run_pdb_script(script, commands) + self.assertNotIn("(1)__annotate__()", result[0]) + def test_step_into_botframe(self): # gh-125422 # pdb should not be able to step into the botframe (bdb.py) From a297926bc6340a32acddac959c5342e493ba75a1 Mon Sep 17 00:00:00 2001 From: PuQing Date: Sun, 13 Jul 2025 12:22:53 +0800 Subject: [PATCH 5/5] Update Lib/test/test_pdb.py Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> --- Lib/test/test_pdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index e8bcc3e3beeabc..b1a6509738c970 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -3817,7 +3817,7 @@ def bar(): self.assertIn('(Pdb) 42', lines) def test_issue135700(self): - """https://github.com/python/cpython/issues/135700""" + # See gh-135700 module_code = """\ 22 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy