-
-
Notifications
You must be signed in to change notification settings - Fork 33k
Description
Bug report
Bug description:
Problem Description
The code has an issue: it's showing an IndentationError in the main() function due to a multiline comment. What's odd is that the error happens even when the comment is indented like another comment that doesn't cause an error.
Steps to Reproduce
- Copy and paste the provided code into a Python environment.
- Execute the program.
Observed Behavior
The program encounters an IndentationError: unindent does not match any outer indentation level during execution due to an apparent inconsistency in multiline comment indentation.
Expected Behavior
The program should execute without any indentation errors. The multiline comment within the main() function, even if indented, should not result in an IndentationError.
How to Solve
To fix the indentation problem, take a close look at the code. Make sure the indentation is consistent by checking for any extra spaces or tabs that could be causing the "IndentationError: unindent does not match any outer indentation level."
Additional notes
I think that this is a weird bug and i don't really see why this couldn't be fixed.
Enviroment
Tested in these environments with these versions.
Python 3.10.12, Python 3.11.2 or Python 3.12.0
Windows 11
Ubuntu 22.04
def main():
"""
This multiline comment will give my program this error:
IndentationError: unindent does not match any outer indentation level
However the comment below will not give an error even tho it is also indented
"""
print("Hello World!")
if __name__ == "__main__":
main()
File "C:\Users\ivar\Desktop\test\main.py", line 7
print("Hello World!")
^
IndentationError: unindent does not match any outer indentation level
CPython versions tested on:
3.10, 3.11, 3.12
Operating systems tested on:
Linux, Windows