Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
Closed
Description
Bug report
Bug description:
In theLib/tabnanny.py module, the exception handling forIndentationError might not be reachable afterSyntaxError is caught and areturn statement is executed.
Seehttps://github.com/python/cpython/blob/main/Lib/tabnanny.py#L108-L114
exceptSyntaxErrorasmsg:errprint("%r: Token Error: %s"% (file,msg))returnexceptIndentationErrorasmsg:errprint("%r: Indentation Error: %s"% (file,msg))return
Why This Happens:
According tohttps://docs.python.org/3/library/exceptions.html#exception-hierarchy , we can learn thatSyntaxError detection range thanIndentationError bigger, Is the inclusion relationship.IndentationError is written afterSyntaxError, which causes the program to never executeIndentationError
How to Fix:
We need to put the more specificIndentationError beforeSyntaxError