| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -84,7 +84,7 @@ Pending removal in Python 3.16 | |||
| 84 | 84 | ||
| 85 | 85 | * :mod:`symtable`: | |
| 86 | 86 | ||
| 87 | - * The :meth:`Class.get_methods <symtable.Class.get_methods>` method | ||
| 87 | + * The :meth:`!symtable.Class.get_methods` method | ||
| 88 | 88 | has been deprecated since Python 3.14. | |
| 89 | 89 | ||
| 90 | 90 | * :mod:`sys`: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -187,57 +187,6 @@ Examining Symbol Tables | |||
| 187 | 187 | ||
| 188 | 188 | A namespace of a class. This class inherits from :class:`SymbolTable`. | |
| 189 | 189 | ||
| 190 | - .. method:: get_methods() | ||
| 191 | - | ||
| 192 | - Return a tuple containing the names of method-like functions declared | ||
| 193 | - in the class. | ||
| 194 | - | ||
| 195 | - Here, the term 'method' designates *any* function defined in the class | ||
| 196 | - body via :keyword:`def` or :keyword:`async def`. | ||
| 197 | - | ||
| 198 | - Functions defined in a deeper scope (e.g., in an inner class) are not | ||
| 199 | - picked up by :meth:`get_methods`. | ||
| 200 | - | ||
| 201 | - For example: | ||
| 202 | - | ||
| 203 | - .. testsetup:: symtable.Class.get_methods | ||
| 204 | - | ||
| 205 | - import warnings | ||
| 206 | - context = warnings.catch_warnings() | ||
| 207 | - context.__enter__() | ||
| 208 | - warnings.simplefilter("ignore", category=DeprecationWarning) | ||
| 209 | - | ||
| 210 | - .. testcleanup:: symtable.Class.get_methods | ||
| 211 | - | ||
| 212 | - context.__exit__() | ||
| 213 | - | ||
| 214 | - .. doctest:: symtable.Class.get_methods | ||
| 215 | - | ||
| 216 | - >>> import symtable | ||
| 217 | - >>> st = symtable.symtable(''' | ||
| 218 | - ... def outer(): pass | ||
| 219 | - ... | ||
| 220 | - ... class A: | ||
| 221 | - ... def f(): | ||
| 222 | - ... def w(): pass | ||
| 223 | - ... | ||
| 224 | - ... def g(self): pass | ||
| 225 | - ... | ||
| 226 | - ... @classmethod | ||
| 227 | - ... async def h(cls): pass | ||
| 228 | - ... | ||
| 229 | - ... global outer | ||
| 230 | - ... def outer(self): pass | ||
| 231 | - ... ''', 'test', 'exec') | ||
| 232 | - >>> class_A = st.get_children()[2] | ||
| 233 | - >>> class_A.get_methods() | ||
| 234 | - ('f', 'g', 'h') | ||
| 235 | - | ||
| 236 | - Although ``A().f()`` raises :exc:`TypeError` at runtime, ``A.f`` is still | ||
| 237 | - considered as a method-like function. | ||
| 238 | - | ||
| 239 | - .. deprecated-removed:: 3.14 3.16 | ||
| 240 | - | ||
| 241 | 190 | ||
| 242 | 191 | .. class:: Symbol | |
| 243 | 192 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,3 +5,6 @@ c-api/allocation.html: deprecated-aliases | |||
| 5 | 5 | c-api/file.html: deprecated-api | |
| 6 | 6 | ||
| 7 | 7 | library/asyncio-task.html: terminating-a-task-group | |
| 8 | + | ||
| 9 | + # Removed APIs | ||
| 10 | + library/symtable.html: symtable.Class.get_methods | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2718,7 +2718,7 @@ New deprecations | |||
| 2718 | 2718 | (Contributed by Tian Gao in :gh:`124369` and :gh:`125951`.) | |
| 2719 | 2719 | ||
| 2720 | 2720 | * :mod:`symtable`: | |
| 2721 | - Deprecate :meth:`symtable.Class.get_methods` due to the lack of interest, | ||
| 2721 | + Deprecate :meth:`!symtable.Class.get_methods` due to the lack of interest, | ||
| 2722 | 2722 | scheduled for removal in Python 3.16. | |
| 2723 | 2723 | (Contributed by Bénédikt Tran in :gh:`119698`.) | |
| 2724 | 2724 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -120,6 +120,12 @@ functools | |||
| 120 | 120 | * Calling the Python implementation of :func:`functools.reduce` with *function* | |
| 121 | 121 | or *sequence* as keyword arguments has been deprecated since Python 3.14. | |
| 122 | 122 | ||
| 123 | + symtable | ||
| 124 | + -------- | ||
| 125 | + | ||
| 126 | + * The :meth:`!symtable.Class.get_methods` method | ||
| 127 | + which has been deprecated since Python 3.14. | ||
| 128 | + | ||
| 123 | 129 | sysconfig | |
| 124 | 130 | --------- | |
| 125 | 131 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -240,41 +240,7 @@ def get_cells(self): | |||
| 240 | 240 | ||
| 241 | 241 | ||
| 242 | 242 | class Class(SymbolTable): | |
| 243 | - | ||
| 244 | - __methods = None | ||
| 245 | - | ||
| 246 | - def get_methods(self): | ||
| 247 | - """Return a tuple of methods declared in the class. | ||
| 248 | - """ | ||
| 249 | - import warnings | ||
| 250 | - typename = f'{self.__class__.__module__}.{self.__class__.__name__}' | ||
| 251 | - warnings.warn(f'{typename}.get_methods() is deprecated ' | ||
| 252 | - f'and will be removed in Python 3.16.', | ||
| 253 | - DeprecationWarning, stacklevel=2) | ||
| 254 | - | ||
| 255 | - if self.__methods is None: | ||
| 256 | - d = {} | ||
| 257 | - | ||
| 258 | - def is_local_symbol(ident): | ||
| 259 | - flags = self._table.symbols.get(ident, 0) | ||
| 260 | - return ((flags >> SCOPE_OFF) & SCOPE_MASK) == LOCAL | ||
| 261 | - | ||
| 262 | - for st in self._table.children: | ||
| 263 | - # pick the function-like symbols that are local identifiers | ||
| 264 | - if is_local_symbol(st.name): | ||
| 265 | - match st.type: | ||
| 266 | - case _symtable.TYPE_FUNCTION: | ||
| 267 | - d[st.name] = 1 | ||
| 268 | - case _symtable.TYPE_TYPE_PARAMETERS: | ||
| 269 | - # Get the function-def block in the annotation | ||
| 270 | - # scope 'st' with the same identifier, if any. | ||
| 271 | - scope_name = st.name | ||
| 272 | - for c in st.children: | ||
| 273 | - if c.name == scope_name and c.type == _symtable.TYPE_FUNCTION: | ||
| 274 | - d[scope_name] = 1 | ||
| 275 | - break | ||
| 276 | - self.__methods = tuple(d) | ||
| 277 | - return self.__methods | ||
| 243 | + pass | ||
| 278 | 244 | ||
| 279 | 245 | ||
| 280 | 246 | class Symbol: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,8 +2,6 @@ | |||
| 2 | 2 | Test the API of the symtable module. | |
| 3 | 3 | """ | |
| 4 | 4 | ||
| 5 | - import re | ||
| 6 | - import textwrap | ||
| 7 | 5 | import symtable | |
| 8 | 6 | import warnings | |
| 9 | 7 | import unittest | |
@@ -364,87 +362,6 @@ def test_name(self): | |||
| 364 | 362 | self.assertEqual(self.spam.lookup("x").get_name(), "x") | |
| 365 | 363 | self.assertEqual(self.Mine.get_name(), "Mine") | |
| 366 | 364 | ||
| 367 | - def test_class_get_methods(self): | ||
| 368 | - deprecation_mess = ( | ||
| 369 | - re.escape('symtable.Class.get_methods() is deprecated ' | ||
| 370 | - 'and will be removed in Python 3.16.') | ||
| 371 | - ) | ||
| 372 | - | ||
| 373 | - with self.assertWarnsRegex(DeprecationWarning, deprecation_mess): | ||
| 374 | - self.assertEqual(self.Mine.get_methods(), ('a_method',)) | ||
| 375 | - | ||
| 376 | - top = symtable.symtable(TEST_COMPLEX_CLASS_CODE, "?", "exec") | ||
| 377 | - this = find_block(top, "ComplexClass") | ||
| 378 | - | ||
| 379 | - with self.assertWarnsRegex(DeprecationWarning, deprecation_mess): | ||
| 380 | - self.assertEqual(this.get_methods(), ( | ||
| 381 | - 'a_method', 'a_method_pep_695', | ||
| 382 | - 'an_async_method', 'an_async_method_pep_695', | ||
| 383 | - 'a_classmethod', 'a_classmethod_pep_695', | ||
| 384 | - 'an_async_classmethod', 'an_async_classmethod_pep_695', | ||
| 385 | - 'a_staticmethod', 'a_staticmethod_pep_695', | ||
| 386 | - 'an_async_staticmethod', 'an_async_staticmethod_pep_695', | ||
| 387 | - 'a_fakemethod', 'a_fakemethod_pep_695', | ||
| 388 | - 'an_async_fakemethod', 'an_async_fakemethod_pep_695', | ||
| 389 | - 'glob_unassigned_meth', 'glob_unassigned_meth_pep_695', | ||
| 390 | - 'glob_unassigned_async_meth', 'glob_unassigned_async_meth_pep_695', | ||
| 391 | - 'glob_assigned_meth', 'glob_assigned_meth_pep_695', | ||
| 392 | - 'glob_assigned_async_meth', 'glob_assigned_async_meth_pep_695', | ||
| 393 | - )) | ||
| 394 | - | ||
| 395 | - # Test generator expressions that are of type TYPE_FUNCTION | ||
| 396 | - # but will not be reported by get_methods() since they are | ||
| 397 | - # not functions per se. | ||
| 398 | - # | ||
| 399 | - # Other kind of comprehensions such as list, set or dict | ||
| 400 | - # expressions do not have the TYPE_FUNCTION type. | ||
| 401 | - | ||
| 402 | - def check_body(body, expected_methods): | ||
| 403 | - indented = textwrap.indent(body, ' ' * 4) | ||
| 404 | - top = symtable.symtable(f"class A:\n{indented}", "?", "exec") | ||
| 405 | - this = find_block(top, "A") | ||
| 406 | - with self.assertWarnsRegex(DeprecationWarning, deprecation_mess): | ||
| 407 | - self.assertEqual(this.get_methods(), expected_methods) | ||
| 408 | - | ||
| 409 | - # statements with 'genexpr' inside it | ||
| 410 | - GENEXPRS = ( | ||
| 411 | - 'x = (x for x in [])', | ||
| 412 | - 'x = (x async for x in [])', | ||
| 413 | - 'type x[genexpr = (x for x in [])] = (x for x in [])', | ||
| 414 | - 'type x[genexpr = (x async for x in [])] = (x async for x in [])', | ||
| 415 | - 'genexpr = (x for x in [])', | ||
| 416 | - 'genexpr = (x async for x in [])', | ||
| 417 | - 'type genexpr[genexpr = (x for x in [])] = (x for x in [])', | ||
| 418 | - 'type genexpr[genexpr = (x async for x in [])] = (x async for x in [])', | ||
| 419 | - ) | ||
| 420 | - | ||
| 421 | - for gen in GENEXPRS: | ||
| 422 | - # test generator expression | ||
| 423 | - with self.subTest(gen=gen): | ||
| 424 | - check_body(gen, ()) | ||
| 425 | - | ||
| 426 | - # test generator expression + variable named 'genexpr' | ||
| 427 | - with self.subTest(gen=gen, isvar=True): | ||
| 428 | - check_body('\n'.join((gen, 'genexpr = 1')), ()) | ||
| 429 | - check_body('\n'.join(('genexpr = 1', gen)), ()) | ||
| 430 | - | ||
| 431 | - for paramlist in ('()', '(x)', '(x, y)', '(z: T)'): | ||
| 432 | - for func in ( | ||
| 433 | - f'def genexpr{paramlist}:pass', | ||
| 434 | - f'async def genexpr{paramlist}:pass', | ||
| 435 | - f'def genexpr[T]{paramlist}:pass', | ||
| 436 | - f'async def genexpr[T]{paramlist}:pass', | ||
| 437 | - ): | ||
| 438 | - with self.subTest(func=func): | ||
| 439 | - # test function named 'genexpr' | ||
| 440 | - check_body(func, ('genexpr',)) | ||
| 441 | - | ||
| 442 | - for gen in GENEXPRS: | ||
| 443 | - with self.subTest(gen=gen, func=func): | ||
| 444 | - # test generator expression + function named 'genexpr' | ||
| 445 | - check_body('\n'.join((gen, func)), ('genexpr',)) | ||
| 446 | - check_body('\n'.join((func, gen)), ('genexpr',)) | ||
| 447 | - | ||
| 448 | 365 | def test_filename_correct(self): | |
| 449 | 366 | ### Bug tickler: SyntaxError file name correct whether error raised | |
| 450 | 367 | ### while parsing or building symbol table. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2038,7 +2038,7 @@ Remove workarounds for non-IEEE 754 systems in :mod:`cmath`. | |||
| 2038 | 2038 | .. nonce: WlygzR | |
| 2039 | 2039 | .. section: Library | |
| 2040 | 2040 | ||
| 2041 | - Due to the lack of interest for :meth:`symtable.Class.get_methods`, the | ||
| 2041 | + Due to the lack of interest for :meth:`!symtable.Class.get_methods`, the | ||
| 2042 | 2042 | method is marked as deprecated and will be removed in Python 3.16. Patch by | |
| 2043 | 2043 | Bénédikt Tran. | |
| 2044 | 2044 | ||
@@ -2746,7 +2746,7 @@ situations. | |||
| 2746 | 2746 | .. nonce: rRrprk | |
| 2747 | 2747 | .. section: Library | |
| 2748 | 2748 | ||
| 2749 | - Fix :meth:`symtable.Class.get_methods` and document its behaviour. Patch by | ||
| 2749 | + Fix :meth:`!symtable.Class.get_methods` and document its behaviour. Patch by | ||
| 2750 | 2750 | Bénédikt Tran. | |
| 2751 | 2751 | ||
| 2752 | 2752 | .. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + Removed :meth:`!symtable.Class.get_methods` which has been deprecated since | ||
| 2 | + 3.14. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments