From b840e4ea1cec50c5e20908b1ff4a20651ed421f8 Mon Sep 17 00:00:00 2001 From: Yash Date: Thu, 8 Jan 2026 13:28:18 +0530 Subject: [PATCH 01/25] symtable commit --- Lib/symtable.py | 13 +++++++++++++ Lib/test/test_symtable.py | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Lib/symtable.py b/Lib/symtable.py index 4c832e68f94cbd..0ca17ae1581726 100644 --- a/Lib/symtable.py +++ b/Lib/symtable.py @@ -184,6 +184,7 @@ class Function(SymbolTable): __frees = None __globals = None __nonlocals = None + __cells = None def __idents_matching(self, test_func): return tuple(ident for ident in self.get_identifiers() @@ -229,6 +230,14 @@ def get_frees(self): self.__frees = self.__idents_matching(is_free) return self.__frees + def get_cells(self): + """Return a tuple of cells in the function.""" + if self.__cells is None: + is_cell = lambda x: _get_scope(x) == CELL + self.__cells = self.__idents_matching(is_cell) + return self.__cells + + class Class(SymbolTable): @@ -342,6 +351,10 @@ def is_free(self): """ return bool(self.__scope == FREE) + def is_cell(self): + """Return *True* if the symbol is a cell variable.""" + return bool(self.__scope == CELL) + def is_free_class(self): """Return *True* if a class-scoped symbol is free from the perspective of a method.""" diff --git a/Lib/test/test_symtable.py b/Lib/test/test_symtable.py index 094ab8f573e7ba..1a972f8d50e173 100644 --- a/Lib/test/test_symtable.py +++ b/Lib/test/test_symtable.py @@ -611,6 +611,22 @@ def test_filter_syntax_warnings_by_module(self): self.assertEqual(wm.filename, filename) self.assertIs(wm.category, SyntaxWarning) + def test_cells(self): + #test for addition of is_cell() and get_cells() + #see https://github.com/python/cpython/issues/143504 + code="""def outer(): + x=1 + def inner(): + return x""" + + top=symtable.symtable(code,"?","exec") + outer=top.get_children()[0] + + self.assertIn("x",outer.get_cells()) + + self.assertTrue(outer.lookup("x").is_cell()) + self.assertFalse(outer.lookup("inner").is_cell()) + class ComprehensionTests(unittest.TestCase): def get_identifiers_recursive(self, st, res): From 0b676e42d9c3306a0986a03cfb48def6b364777a Mon Sep 17 00:00:00 2001 From: Yashraj Date: Thu, 8 Jan 2026 16:17:19 +0530 Subject: [PATCH 02/25] symtable fix 1 Co-authored-by: AN Long --- Lib/symtable.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/symtable.py b/Lib/symtable.py index 0ca17ae1581726..b22149f4f7794e 100644 --- a/Lib/symtable.py +++ b/Lib/symtable.py @@ -238,7 +238,6 @@ def get_cells(self): return self.__cells - class Class(SymbolTable): __methods = None From 2175829e698f01a7f555dcb3ee09a30879de09c0 Mon Sep 17 00:00:00 2001 From: Yash Date: Thu, 8 Jan 2026 16:28:33 +0530 Subject: [PATCH 03/25] symtable fix 2- news --- .../2026-01-08-16-28-03.gh-issue-143504.PlC_Yv.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2026-01-08-16-28-03.gh-issue-143504.PlC_Yv.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-08-16-28-03.gh-issue-143504.PlC_Yv.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-08-16-28-03.gh-issue-143504.PlC_Yv.rst new file mode 100644 index 00000000000000..a4692f9c36777a --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-08-16-28-03.gh-issue-143504.PlC_Yv.rst @@ -0,0 +1 @@ +Add symtable.is_cell() and get_cells() methods for cell variable analysis. From 17072bdae2f20519bc7ac148dedf98c253809279 Mon Sep 17 00:00:00 2001 From: Yash Date: Wed, 21 Jan 2026 15:51:46 +0530 Subject: [PATCH 04/25] symtable fix 3 --- Lib/symtable.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Lib/symtable.py b/Lib/symtable.py index b22149f4f7794e..a4caaa6c0c392c 100644 --- a/Lib/symtable.py +++ b/Lib/symtable.py @@ -171,6 +171,11 @@ def get_children(self): return [_newSymbolTable(st, self._filename) for st in self._table.children] + def get_cells(self): + """Return a list of cell variable names in the table.""" + return [s.get_name() for s in self.get_symbols() if s.is_cell()] + + def _get_scope(flags): # like _PyST_GetScope() return (flags >> SCOPE_OFF) & SCOPE_MASK @@ -230,13 +235,6 @@ def get_frees(self): self.__frees = self.__idents_matching(is_free) return self.__frees - def get_cells(self): - """Return a tuple of cells in the function.""" - if self.__cells is None: - is_cell = lambda x: _get_scope(x) == CELL - self.__cells = self.__idents_matching(is_cell) - return self.__cells - class Class(SymbolTable): From f09648869f1eee1487b3fcde09bfdea7768dd4d2 Mon Sep 17 00:00:00 2001 From: Yash Date: Wed, 21 Jan 2026 16:58:48 +0530 Subject: [PATCH 05/25] symtable fix 4 --- Lib/test/test_symtable.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Lib/test/test_symtable.py b/Lib/test/test_symtable.py index 1a972f8d50e173..9a47ef9973574e 100644 --- a/Lib/test/test_symtable.py +++ b/Lib/test/test_symtable.py @@ -620,10 +620,8 @@ def inner(): return x""" top=symtable.symtable(code,"?","exec") - outer=top.get_children()[0] - + outer = find_block(top, "outer") self.assertIn("x",outer.get_cells()) - self.assertTrue(outer.lookup("x").is_cell()) self.assertFalse(outer.lookup("inner").is_cell()) From 57b36be4f7818758aa4f71b00124da74abcc4b02 Mon Sep 17 00:00:00 2001 From: Yash Date: Wed, 21 Jan 2026 23:27:40 +0530 Subject: [PATCH 06/25] symtable fix 5 --- Lib/symtable.py | 9 ++++----- Lib/test/test_symtable.py | 28 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Lib/symtable.py b/Lib/symtable.py index a4caaa6c0c392c..29fb74680f4543 100644 --- a/Lib/symtable.py +++ b/Lib/symtable.py @@ -171,10 +171,6 @@ def get_children(self): return [_newSymbolTable(st, self._filename) for st in self._table.children] - def get_cells(self): - """Return a list of cell variable names in the table.""" - return [s.get_name() for s in self.get_symbols() if s.is_cell()] - def _get_scope(flags): # like _PyST_GetScope() @@ -189,7 +185,6 @@ class Function(SymbolTable): __frees = None __globals = None __nonlocals = None - __cells = None def __idents_matching(self, test_func): return tuple(ident for ident in self.get_identifiers() @@ -235,6 +230,10 @@ def get_frees(self): self.__frees = self.__idents_matching(is_free) return self.__frees + def get_cells(self): + """Return a list of cell variable names in the table.""" + return [s.get_name() for s in self.get_symbols() if s.is_cell()] + class Class(SymbolTable): diff --git a/Lib/test/test_symtable.py b/Lib/test/test_symtable.py index 9a47ef9973574e..164e1068a6b1db 100644 --- a/Lib/test/test_symtable.py +++ b/Lib/test/test_symtable.py @@ -284,6 +284,20 @@ def test_local(self): def test_free(self): self.assertTrue(self.internal.lookup("x").is_free()) + def test_cells(self): + #test for addition of is_cell() and get_cells() + #see https://github.com/python/cpython/issues/143504 + code="""def outer(): + x=1 + def inner(): + return x""" + + top=symtable.symtable(code,"?","exec") + outer = find_block(top, "outer") + self.assertIn("x",outer.get_cells()) + self.assertTrue(outer.lookup("x").is_cell()) + self.assertFalse(outer.lookup("inner").is_cell()) + def test_referenced(self): self.assertTrue(self.internal.lookup("x").is_referenced()) self.assertTrue(self.spam.lookup("internal").is_referenced()) @@ -611,20 +625,6 @@ def test_filter_syntax_warnings_by_module(self): self.assertEqual(wm.filename, filename) self.assertIs(wm.category, SyntaxWarning) - def test_cells(self): - #test for addition of is_cell() and get_cells() - #see https://github.com/python/cpython/issues/143504 - code="""def outer(): - x=1 - def inner(): - return x""" - - top=symtable.symtable(code,"?","exec") - outer = find_block(top, "outer") - self.assertIn("x",outer.get_cells()) - self.assertTrue(outer.lookup("x").is_cell()) - self.assertFalse(outer.lookup("inner").is_cell()) - class ComprehensionTests(unittest.TestCase): def get_identifiers_recursive(self, st, res): From 5c558f448f4baa5491951228d0df1136584b3a77 Mon Sep 17 00:00:00 2001 From: Yash Date: Wed, 21 Jan 2026 23:28:44 +0530 Subject: [PATCH 07/25] symtable fix 5 --- Lib/symtable.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/symtable.py b/Lib/symtable.py index 29fb74680f4543..544211c98a6f62 100644 --- a/Lib/symtable.py +++ b/Lib/symtable.py @@ -172,7 +172,6 @@ def get_children(self): for st in self._table.children] - def _get_scope(flags): # like _PyST_GetScope() return (flags >> SCOPE_OFF) & SCOPE_MASK From a9e5bf75e7ec79ceb6cc657eaf3c367c8f7d917c Mon Sep 17 00:00:00 2001 From: Yash Date: Thu, 22 Jan 2026 15:53:22 +0530 Subject: [PATCH 08/25] symtable fix 6 --- Lib/symtable.py | 8 ++++++-- Lib/test/test_symtable.py | 5 ++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Lib/symtable.py b/Lib/symtable.py index 544211c98a6f62..33c8d0bd23efa1 100644 --- a/Lib/symtable.py +++ b/Lib/symtable.py @@ -184,6 +184,7 @@ class Function(SymbolTable): __frees = None __globals = None __nonlocals = None + __cells = None def __idents_matching(self, test_func): return tuple(ident for ident in self.get_identifiers() @@ -230,8 +231,11 @@ def get_frees(self): return self.__frees def get_cells(self): - """Return a list of cell variable names in the table.""" - return [s.get_name() for s in self.get_symbols() if s.is_cell()] + """Return a list of cell variable names in the table. + """ + if self.__cells is None: + self.__cells = [s.get_name() for s in self.get_symbols() if s.is_cell()] + return self.__cells class Class(SymbolTable): diff --git a/Lib/test/test_symtable.py b/Lib/test/test_symtable.py index 164e1068a6b1db..cb05d5fcbf457c 100644 --- a/Lib/test/test_symtable.py +++ b/Lib/test/test_symtable.py @@ -285,8 +285,7 @@ def test_free(self): self.assertTrue(self.internal.lookup("x").is_free()) def test_cells(self): - #test for addition of is_cell() and get_cells() - #see https://github.com/python/cpython/issues/143504 + code="""def outer(): x=1 def inner(): @@ -294,7 +293,7 @@ def inner(): top=symtable.symtable(code,"?","exec") outer = find_block(top, "outer") - self.assertIn("x",outer.get_cells()) + self.assertEqual(outer.get_cells(), ["x"]) self.assertTrue(outer.lookup("x").is_cell()) self.assertFalse(outer.lookup("inner").is_cell()) From f437b13d2838e9ecb7e4bac566e20af3790aa8a5 Mon Sep 17 00:00:00 2001 From: Yash Date: Fri, 23 Jan 2026 23:45:07 +0530 Subject: [PATCH 09/25] symtable fix 6 --- Lib/test/test_symtable.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Lib/test/test_symtable.py b/Lib/test/test_symtable.py index cb05d5fcbf457c..8e5af65385ede2 100644 --- a/Lib/test/test_symtable.py +++ b/Lib/test/test_symtable.py @@ -285,17 +285,8 @@ def test_free(self): self.assertTrue(self.internal.lookup("x").is_free()) def test_cells(self): + self.assertTrue(self.spam.lookup("x").is_cell()) - code="""def outer(): - x=1 - def inner(): - return x""" - - top=symtable.symtable(code,"?","exec") - outer = find_block(top, "outer") - self.assertEqual(outer.get_cells(), ["x"]) - self.assertTrue(outer.lookup("x").is_cell()) - self.assertFalse(outer.lookup("inner").is_cell()) def test_referenced(self): self.assertTrue(self.internal.lookup("x").is_referenced()) From 54c8de1c63c5e3603c80dc64ad1659a05a77ca5c Mon Sep 17 00:00:00 2001 From: Yashraj Date: Sat, 24 Jan 2026 13:24:37 +0530 Subject: [PATCH 10/25] symtable fix 7 Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> --- Lib/symtable.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/symtable.py b/Lib/symtable.py index 33c8d0bd23efa1..d6b928fa5db518 100644 --- a/Lib/symtable.py +++ b/Lib/symtable.py @@ -234,7 +234,8 @@ def get_cells(self): """Return a list of cell variable names in the table. """ if self.__cells is None: - self.__cells = [s.get_name() for s in self.get_symbols() if s.is_cell()] + is_cell = lambda x: _get_scope(x) == CELL + self.__cells = self.__idents_matching(is_cell) return self.__cells From 3732812678a2f3846fbf69019ea483cd701a9c04 Mon Sep 17 00:00:00 2001 From: Yashraj Date: Sat, 24 Jan 2026 13:24:57 +0530 Subject: [PATCH 11/25] symtable fix 8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --- Lib/symtable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/symtable.py b/Lib/symtable.py index d6b928fa5db518..7a9c189d331ac8 100644 --- a/Lib/symtable.py +++ b/Lib/symtable.py @@ -231,7 +231,7 @@ def get_frees(self): return self.__frees def get_cells(self): - """Return a list of cell variable names in the table. + """Return a tuple of cell variable names in the table. """ if self.__cells is None: is_cell = lambda x: _get_scope(x) == CELL From d36cd8442eb939cc6273d7e80eaf7b7c6e2f5d63 Mon Sep 17 00:00:00 2001 From: Yashraj Date: Sat, 24 Jan 2026 13:25:12 +0530 Subject: [PATCH 12/25] symtable fix 8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --- Lib/test/test_symtable.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/test/test_symtable.py b/Lib/test/test_symtable.py index 8e5af65385ede2..5bf461f11dc61b 100644 --- a/Lib/test/test_symtable.py +++ b/Lib/test/test_symtable.py @@ -287,7 +287,6 @@ def test_free(self): def test_cells(self): self.assertTrue(self.spam.lookup("x").is_cell()) - def test_referenced(self): self.assertTrue(self.internal.lookup("x").is_referenced()) self.assertTrue(self.spam.lookup("internal").is_referenced()) From a1ebb6951da0fb2eb1b84e411ad231fae3c7fb67 Mon Sep 17 00:00:00 2001 From: Yash Date: Sat, 24 Jan 2026 13:50:00 +0530 Subject: [PATCH 13/25] symtable fix 9 --- Doc/library/symtable.rst | 10 ++++++++++ Lib/test/test_symtable.py | 1 + .../2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst | 2 ++ 3 files changed, 13 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst diff --git a/Doc/library/symtable.rst b/Doc/library/symtable.rst index f5e6f9f8acfdb8..1af01895a8b57e 100644 --- a/Doc/library/symtable.rst +++ b/Doc/library/symtable.rst @@ -180,6 +180,10 @@ Examining Symbol Tables Return a tuple containing names of :term:`free (closure) variables ` in this function. + .. method:: get_cells() + + Return a tuple containing the names of cell variables in this table. + .. class:: Class @@ -353,6 +357,12 @@ Examining Symbol Tables Return the namespace bound to this name. If more than one or no namespace is bound to this name, a :exc:`ValueError` is raised. + .. method:: is_cell() + + Return ``True`` if the symbol is a cell variable. + + .. versionadded:: 3.15 + .. _symtable-cli: diff --git a/Lib/test/test_symtable.py b/Lib/test/test_symtable.py index 5bf461f11dc61b..c748243110df9f 100644 --- a/Lib/test/test_symtable.py +++ b/Lib/test/test_symtable.py @@ -255,6 +255,7 @@ def test_function_info(self): self.assertEqual(sorted(func.get_locals()), expected) self.assertEqual(sorted(func.get_globals()), ["bar", "glob", "some_assigned_global_var"]) self.assertEqual(self.internal.get_frees(), ("x",)) + self.assertEqual(self.spam.get_cells(), ("some_var", "x",)) def test_globals(self): self.assertTrue(self.spam.lookup("glob").is_global()) diff --git a/Misc/NEWS.d/next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst b/Misc/NEWS.d/next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst new file mode 100644 index 00000000000000..a1d137fca6c00d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst @@ -0,0 +1,2 @@ +Add :meth:`symtable.SymbolTable.get_cells` and +:meth:`symtable.Symbol.is_cell` methods. From 611d4d3fa0a1c4d7c3251fb4a3a2b6391311aae4 Mon Sep 17 00:00:00 2001 From: Yash Date: Sat, 24 Jan 2026 17:09:39 +0530 Subject: [PATCH 14/25] symtable fix 9 --- Doc/library/symtable.rst | 14 +++++++------- Doc/whatsnew/3.15.rst | 8 ++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Doc/library/symtable.rst b/Doc/library/symtable.rst index 1af01895a8b57e..7dbf70311553b5 100644 --- a/Doc/library/symtable.rst +++ b/Doc/library/symtable.rst @@ -182,7 +182,7 @@ Examining Symbol Tables .. method:: get_cells() - Return a tuple containing the names of cell variables in this table. + Return a tuple containing names of :term:`cell variables ` in this table. .. class:: Class @@ -295,6 +295,12 @@ Examining Symbol Tables Return ``True`` if the symbol is referenced in its block, but not assigned to. + .. method:: is_cell() + + Return ``True`` if the symbol is a cell variable. + + .. versionadded:: 3.15 + .. method:: is_free_class() Return *True* if a class-scoped symbol is free from @@ -357,12 +363,6 @@ Examining Symbol Tables Return the namespace bound to this name. If more than one or no namespace is bound to this name, a :exc:`ValueError` is raised. - .. method:: is_cell() - - Return ``True`` if the symbol is a cell variable. - - .. versionadded:: 3.15 - .. _symtable-cli: diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 1d4961d7293631..7ee3126bc4404e 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -737,6 +737,14 @@ ssl (Contributed by Ron Frederick in :gh:`138252`.) +symtable +-------- + +* Add :meth:`symtable.SymbolTable.get_cells` and + :meth:`symtable.Symbol.is_cell` methods. + (Contributed by Yashp002 in :gh:`143504`.) + + sys --- From 700a24ffa29e26d3dd901a1ec986a83cfc461141 Mon Sep 17 00:00:00 2001 From: Yash Date: Sat, 24 Jan 2026 17:16:03 +0530 Subject: [PATCH 15/25] symtable fix 10 --- Doc/whatsnew/3.15.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 7ee3126bc4404e..b6ad602e46bb1b 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -740,8 +740,8 @@ ssl symtable -------- -* Add :meth:`symtable.SymbolTable.get_cells` and - :meth:`symtable.Symbol.is_cell` methods. +* Add :meth:`symtable.SymbolTable.Function.get_cells` and :meth:`symtable.Symbol.is_cell` methods. + (Contributed by Yashp002 in :gh:`143504`.) From 2b96cb53a9e658a8b96537f698b1c1ac0e9d52c2 Mon Sep 17 00:00:00 2001 From: Yash Date: Sat, 24 Jan 2026 17:32:51 +0530 Subject: [PATCH 16/25] symtable fix 10 --- Doc/whatsnew/3.15.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index b6ad602e46bb1b..c52aa4fe1b2aac 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -740,7 +740,7 @@ ssl symtable -------- -* Add :meth:`symtable.SymbolTable.Function.get_cells` and :meth:`symtable.Symbol.is_cell` methods. +* Add :meth:`symtable.Function.get_cells` and :meth:`symtable.Symbol.is_cell` methods. (Contributed by Yashp002 in :gh:`143504`.) From 8c3a597f3a3a1e8625e5973b65890827604c7dac Mon Sep 17 00:00:00 2001 From: Yashraj Date: Sat, 24 Jan 2026 20:56:52 +0530 Subject: [PATCH 17/25] symtable fix Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> --- Doc/library/symtable.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/symtable.rst b/Doc/library/symtable.rst index 7dbf70311553b5..a9653c8ed6e96f 100644 --- a/Doc/library/symtable.rst +++ b/Doc/library/symtable.rst @@ -297,7 +297,7 @@ Examining Symbol Tables .. method:: is_cell() - Return ``True`` if the symbol is a cell variable. + Return ``True`` if the symbol is referenced from a nested block. .. versionadded:: 3.15 From b36df01c075aa9e8af1d0f32c6a72883c7d5ffb8 Mon Sep 17 00:00:00 2001 From: Yashraj Date: Sat, 24 Jan 2026 20:57:07 +0530 Subject: [PATCH 18/25] Update Doc/whatsnew/3.15.rst Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> --- Doc/whatsnew/3.15.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index c52aa4fe1b2aac..4b678e49a44533 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -741,7 +741,6 @@ symtable -------- * Add :meth:`symtable.Function.get_cells` and :meth:`symtable.Symbol.is_cell` methods. - (Contributed by Yashp002 in :gh:`143504`.) From 253935764339e55066177c8d2bd34199856d01ba Mon Sep 17 00:00:00 2001 From: Yash Date: Sat, 24 Jan 2026 21:02:55 +0530 Subject: [PATCH 19/25] symtable fix 11 --- .../2026-01-08-16-28-03.gh-issue-143504.PlC_Yv.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2026-01-08-16-28-03.gh-issue-143504.PlC_Yv.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-08-16-28-03.gh-issue-143504.PlC_Yv.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-08-16-28-03.gh-issue-143504.PlC_Yv.rst deleted file mode 100644 index a4692f9c36777a..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-08-16-28-03.gh-issue-143504.PlC_Yv.rst +++ /dev/null @@ -1 +0,0 @@ -Add symtable.is_cell() and get_cells() methods for cell variable analysis. From b8df6598f734438d35bad7412475dcee12f80e5e Mon Sep 17 00:00:00 2001 From: Yash Date: Sat, 24 Jan 2026 21:08:12 +0530 Subject: [PATCH 20/25] symtable fix 11 --- .../Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS.d/next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst b/Misc/NEWS.d/next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst index a1d137fca6c00d..ab2c3dc106b471 100644 --- a/Misc/NEWS.d/next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst +++ b/Misc/NEWS.d/next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst @@ -1,2 +1,2 @@ -Add :meth:`symtable.SymbolTable.get_cells` and -:meth:`symtable.Symbol.is_cell` methods. +Add :meth:`symtable.Function.get_cells` and :meth:`symtable.Symbol.is_cell` methods. + From 68653ee4ef05e77ce0e933979e097cbc91a6c4e6 Mon Sep 17 00:00:00 2001 From: Yashraj Date: Sun, 25 Jan 2026 12:22:55 +0530 Subject: [PATCH 21/25] Update Doc/library/symtable.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --- Doc/library/symtable.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/symtable.rst b/Doc/library/symtable.rst index a9653c8ed6e96f..051f8d001b6e64 100644 --- a/Doc/library/symtable.rst +++ b/Doc/library/symtable.rst @@ -299,7 +299,7 @@ Examining Symbol Tables Return ``True`` if the symbol is referenced from a nested block. - .. versionadded:: 3.15 + .. versionadded:: next .. method:: is_free_class() From 6a6da413145ef5bd489b1e91c2779cb23fcfaaea Mon Sep 17 00:00:00 2001 From: Yash Date: Sun, 25 Jan 2026 12:24:36 +0530 Subject: [PATCH 22/25] symtable fix 12 --- Doc/library/symtable.rst | 2 ++ .../Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/library/symtable.rst b/Doc/library/symtable.rst index 051f8d001b6e64..5bd57aa3f5cf64 100644 --- a/Doc/library/symtable.rst +++ b/Doc/library/symtable.rst @@ -184,6 +184,8 @@ Examining Symbol Tables Return a tuple containing names of :term:`cell variables ` in this table. + .. versionadded:: next + .. class:: Class diff --git a/Misc/NEWS.d/next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst b/Misc/NEWS.d/next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst index ab2c3dc106b471..b2c0f14299b89b 100644 --- a/Misc/NEWS.d/next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst +++ b/Misc/NEWS.d/next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst @@ -1,2 +1 @@ -Add :meth:`symtable.Function.get_cells` and :meth:`symtable.Symbol.is_cell` methods. - +Add :meth:`symtable.Function.get_cells` and :meth:`symtable.Symbol.is_cell` methods. \ No newline at end of file From b5e8482edcad3ec45897ddc7420663e9268ac1bb Mon Sep 17 00:00:00 2001 From: Yash Date: Sun, 25 Jan 2026 13:32:14 +0530 Subject: [PATCH 23/25] symtable fix 12 --- .../next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst b/Misc/NEWS.d/next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst index b2c0f14299b89b..e0c2c287f57271 100644 --- a/Misc/NEWS.d/next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst +++ b/Misc/NEWS.d/next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst @@ -1 +1 @@ -Add :meth:`symtable.Function.get_cells` and :meth:`symtable.Symbol.is_cell` methods. \ No newline at end of file +Add :meth:`symtable.Function.get_cells` and :meth:`symtable.Symbol.is_cell` methods. From 14a6c287a52987d10c04c71e0a309804ef0bd919 Mon Sep 17 00:00:00 2001 From: Yashraj Date: Sun, 25 Jan 2026 18:44:46 +0530 Subject: [PATCH 24/25] Update Lib/symtable.py Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> --- Lib/symtable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/symtable.py b/Lib/symtable.py index 7a9c189d331ac8..45610fd5612995 100644 --- a/Lib/symtable.py +++ b/Lib/symtable.py @@ -231,7 +231,7 @@ def get_frees(self): return self.__frees def get_cells(self): - """Return a tuple of cell variable names in the table. + """Return a tuple of cell variables in the function. """ if self.__cells is None: is_cell = lambda x: _get_scope(x) == CELL From a8bb25a6cdda64d59d47fb6c2269ea4c628200a7 Mon Sep 17 00:00:00 2001 From: Yashraj Date: Sun, 25 Jan 2026 18:44:56 +0530 Subject: [PATCH 25/25] Update Doc/library/symtable.rst Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> --- Doc/library/symtable.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/symtable.rst b/Doc/library/symtable.rst index 5bd57aa3f5cf64..0b722d7d4e35cf 100644 --- a/Doc/library/symtable.rst +++ b/Doc/library/symtable.rst @@ -299,7 +299,7 @@ Examining Symbol Tables .. method:: is_cell() - Return ``True`` if the symbol is referenced from a nested block. + Return ``True`` if the symbol is referenced but not assigned in a nested block. .. versionadded:: next