-
-
Couldn't load subscription status.
- Fork 33.3k
Closed as duplicate of#139838
Closed as duplicate of#139838
Copy link
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
Off by one error in extracting the source with inspect.getsourcelines When there is a more than one line break between the decorator and the function definition.
import inspect
decorator = lambda fn: fn
@decorator
# Hello World
def decorated(a, b):
return a + b
code, _lnum = inspect.getsourcelines(decorated)
print("".join(code))Running with 3.13.7 gives
@decorator
# Hello World
def decorated(a, b):
return a + bRunning with 3.13.8 gives:
@decorator
# Hello World
def decorated(a, b):
Doesn't have to be a comment
@decorator
def decorated(a, b):
...produces the behavior and multiple line breaks still give the same off by one error.
CPython versions tested on:
3.13
Operating systems tested on:
macOS
Metadata
Metadata
Assignees
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error