Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc206582

Browse files
[3.11]gh-109207: Fix SystemError when printing symtable entry object. (GH-109225) (GH-109228)
(cherry picked from commit4297499)Co-authored-by: 云line <31395137+yunline@users.noreply.github.com>
1 parent77356f6 commitc206582

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

‎Lib/test/test_symtable.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ def test_symtable_repr(self):
252252
self.assertEqual(str(self.top),"<SymbolTable for module ?>")
253253
self.assertEqual(str(self.spam),"<Function SymbolTable for spam in ?>")
254254

255+
deftest_symtable_entry_repr(self):
256+
expected=f"<symtable entry top({self.top.get_id()}), line{self.top.get_lineno()}>"
257+
self.assertEqual(repr(self.top._table),expected)
258+
255259

256260
if__name__=='__main__':
257261
unittest.main()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a SystemError in ``__repr__`` of symtable entry object.

‎Python/symtable.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,8 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block,
128128
staticPyObject*
129129
ste_repr(PySTEntryObject*ste)
130130
{
131-
returnPyUnicode_FromFormat("<symtable entry %U(%ld), line %d>",
132-
ste->ste_name,
133-
PyLong_AS_LONG(ste->ste_id),ste->ste_lineno);
131+
returnPyUnicode_FromFormat("<symtable entry %U(%R), line %d>",
132+
ste->ste_name,ste->ste_id,ste->ste_lineno);
134133
}
135134

136135
staticvoid

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp