-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect code collapse while prompting where the error is. #128327
Comments
This the the expected behaviour. Because we are running If you unroll the calls you have: fib(2) -> fib(1) + fib(0)
fib(1) -> 1
fib(0) -> assertion error So it's normal that
So the error happened in the n-2 inner branch of the top n-1 branch. It would also fail on the n-2 inner branch of the top n-2 branch but this n-2 branch wouldn't be even executed yet. This can be verified as follows: def fib(number: int, s='') -> int:
print("called with:", number, s)
assert number > 0, (number, s)
if number == 1: return 1
return fib(number - 1, s + 'l') + fib(number - 2, s + "r")
fib(5) This wil print:
|
Thanks for reading my issue! I am sorry that I may have not explained myself clearly.
That is to say, while calculating fib(2), the former, fib(number - 1) has been calculated successfully, and the mistake happened while calculating fib(number - 2), which refers to fib(0)
|
Ah I see what you mean. I think the issue is that we are considering the traceback to be identical because we haven't yet added the markers ( For instance,
cc @pablogsal |
Bug report
Bug description:
Read the following code:
There is a mistake in the code above, so if you try to run it, you will get the following traceback:
Notice that the error happened while running the code fib(number - 2).
However, if the number is 5, the duplicate code will be automatically collapsed:
The error happened in fib(number - 2). However, in the traceback above, I can only suppose the error happened while running fib(number - 1), which increases the time to find where the real bug is.
CPython versions tested on:
3.13, 3.14
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: