diff options
author | Karthikeyan Singaravelan <tir.karthi@gmail.com> | 2020-04-18 16:19:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-18 16:19:32 (GMT) |
commit | 696136b993e11b37c4f34d729a0375e5ad544ade (patch) | |
tree | 19b1085d34db9d665b8f131e3f99bd0c2a40fcb6 /Lib/test/inspect_fodder2.py | |
parent | ce578831a4e573eac422a488930100bc5380f227 (diff) | |
download | cpython-696136b993e11b37c4f34d729a0375e5ad544ade.zip cpython-696136b993e11b37c4f34d729a0375e5ad544ade.tar.gz cpython-696136b993e11b37c4f34d729a0375e5ad544ade.tar.bz2 |
bpo-35113: Fix inspect.getsource to return correct source for inner classes (#10307)
* Use ast module to find class definition
* Add NEWS entry
* Fix class with multiple children and move decorator code to the method
* Fix PR comments
1. Use node.decorator_list to select decorators
2. Remove unwanted variables in ClassVisitor
3. Simplify stack management as per review
* Add test for nested functions and async calls
* Fix pydoc test since comments are returned now correctly
* Set event loop policy as None to fix environment related change
* Refactor visit_AsyncFunctionDef and tests
* Refactor to use local variables and fix tests
* Add patch attribution
* Use self.addCleanup for asyncio
* Rename ClassVisitor to ClassFinder and fix asyncio cleanup
* Return first class inside conditional in case of multiple definitions. Remove decorator for class source.
* Add docstring to make the test correct
* Modify NEWS entry regarding decorators
* Return decorators too for bpo-15856
* Move ast and the class source code to top. Use proper Exception.
Diffstat (limited to 'Lib/test/inspect_fodder2.py')
-rw-r--r-- | Lib/test/inspect_fodder2.py | 114 |
1 files changed, 110 insertions, 4 deletions
diff --git a/Lib/test/inspect_fodder2.py b/Lib/test/inspect_fodder2.py index 5a7b559..e7d4b53 100644 --- a/Lib/test/inspect_fodder2.py +++ b/Lib/test/inspect_fodder2.py @@ -138,18 +138,124 @@ class cls135: never_reached1 never_reached2 -#line 141 +# line 141 +class cls142: + a = """ +class cls149: + ... +""" + +# line 148 +class cls149: + + def func151(self): + pass + +''' +class cls160: + pass +''' + +# line 159 +class cls160: + + def func162(self): + pass + +# line 165 +class cls166: + a = ''' + class cls175: + ... + ''' + +# line 172 +class cls173: + + class cls175: + pass + +# line 178 +class cls179: + pass + +# line 182 +class cls183: + + class cls185: + + def func186(self): + pass + +def class_decorator(cls): + return cls + +# line 193 +@class_decorator +@class_decorator +class cls196: + + @class_decorator + @class_decorator + class cls200: + pass + +class cls203: + class cls204: + class cls205: + pass + class cls207: + class cls205: + pass + +# line 211 +def func212(): + class cls213: + pass + return cls213 + +# line 217 +class cls213: + def func219(self): + class cls220: + pass + return cls220 + +# line 224 +async def func225(): + class cls226: + pass + return cls226 + +# line 230 +class cls226: + async def func232(self): + class cls233: + pass + return cls233 + +if True: + class cls238: + class cls239: + '''if clause cls239''' +else: + class cls238: + class cls239: + '''else clause 239''' + pass + +#line 247 def positional_only_arg(a, /): pass -#line 145 +#line 251 def all_markers(a, b, /, c, d, *, e, f): pass -# line 149 +# line 255 def all_markers_with_args_and_kwargs(a, b, /, c, d, *args, e, f, **kwargs): pass -#line 153 +#line 259 def all_markers_with_defaults(a, b=1, /, c=2, d=3, *, e=4, f=5): pass |