From be8255ad8c3af2ccd452cfdfae10bd72e966cb25 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Mon, 2 Oct 2023 07:55:41 -0700 Subject: [3.12] gh-109207: Fix SystemError when printing symtable entry object. (GH-109225) (#109227) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gh-109207: Fix SystemError when printing symtable entry object. (GH-109225) (cherry picked from commit 429749969621b149c1a7c3c004bd44f52bec8f44) Co-authored-by: δΊ‘line <31395137+yunline@users.noreply.github.com> --- Lib/test/test_symtable.py | 4 ++++ .../Core and Builtins/2023-09-10-18-53-55.gh-issue-109207.Fei8bY.rst | 1 + Python/symtable.c | 5 ++--- 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2023-09-10-18-53-55.gh-issue-109207.Fei8bY.rst diff --git a/Lib/test/test_symtable.py b/Lib/test/test_symtable.py index 61fda76..82c1d7c 100644 --- a/Lib/test/test_symtable.py +++ b/Lib/test/test_symtable.py @@ -282,6 +282,10 @@ class SymtableTest(unittest.TestCase): self.assertEqual(str(self.top), "") self.assertEqual(str(self.spam), "") + def test_symtable_entry_repr(self): + expected = f"" + self.assertEqual(repr(self.top._table), expected) + if __name__ == '__main__': unittest.main() diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-09-10-18-53-55.gh-issue-109207.Fei8bY.rst b/Misc/NEWS.d/next/Core and Builtins/2023-09-10-18-53-55.gh-issue-109207.Fei8bY.rst new file mode 100644 index 0000000..f9da3ac --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2023-09-10-18-53-55.gh-issue-109207.Fei8bY.rst @@ -0,0 +1 @@ +Fix a SystemError in ``__repr__`` of symtable entry object. diff --git a/Python/symtable.c b/Python/symtable.c index 8651812..70b6eac 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -150,9 +150,8 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block, static PyObject * ste_repr(PySTEntryObject *ste) { - return PyUnicode_FromFormat("", - ste->ste_name, - PyLong_AS_LONG(ste->ste_id), ste->ste_lineno); + return PyUnicode_FromFormat("", + ste->ste_name, ste->ste_id, ste->ste_lineno); } static void -- cgit v0.12