From: δΊ‘line <31395137+yunline@users.noreply.github.com> Date: Sun, 10 Sep 2023 12:04:24 +0000 (+0800) Subject: gh-109207: Fix SystemError when printing symtable entry object. (GH-109225) X-Git-Tag: v3.13.0a1~509 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=429749969621b149c1a7c3c004bd44f52bec8f44;p=thirdparty%2FPython%2Fcpython.git gh-109207: Fix SystemError when printing symtable entry object. (GH-109225) --- diff --git a/Lib/test/test_symtable.py b/Lib/test/test_symtable.py index 25714aecda3a..36cb7b3f242e 100644 --- a/Lib/test/test_symtable.py +++ b/Lib/test/test_symtable.py @@ -251,6 +251,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 000000000000..f9da3ac4d1ab --- /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 7eef6f7231c0..6c28b49a0655 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