Page MenuHome

blender 2.8 malfunctions when reporting an indentation error executing a python script
Closed, DuplicatePublic

Description

System Information
Operating system: Linux
Graphics card: NVIDIA Corporation GP106M [GeForce GTX 1060 Mobile]

Blender Version
Broken: version: 2.80 (sub 75), branch: master, commit date: 2019-07-29 14:47, hash: f6cb5f54494e, type: Release
Worked: 2.79

when using the [Run Script] button in the text panel if the script has an indentation error the message sent to stdout (or stderr?) just says

AttributeError: 'IndentationError' object has no attribute 'msg'
Error: Python script failed, check the message in the system console

while older versions (like 2.79) would give a much more detailed message like

Error:   File "/triangle_anim_2.py", line 129
    def make_dot(loc, base, arm, i, mat):
      ^
IndentationError: expected an indented block

and highlight some text near the error in the text buffer

Exact steps for others to reproduce the error

try to run the following python script inside the editor:

def bacon():
    
def eggs():
    pass

Event Timeline

I can't redo this error, in 2.80, I get the same behavior as 2.7x

Could you try run this:

print(IndentationError().msg)

Campbell Barton (campbellbarton) lowered the priority of this task from 90 to 30.Aug 19 2019, 9:56 PM

Quite strangely everything works correctly when trying that line of code, but if I restart Blender and do the following I get the non descriptive indentation error:

Quite strangely everything works correctly when trying that line of code, but if I restart Blender and do the following I get the non descriptive indentation error:

yeah, thats where i ran into the error also, i had a subindented block with a 3 space indent instead of 4, and it was impossible to find - had to import the file into pycharm.

Bastien Montagne (mont29) raised the priority of this task from 30 to 80.Aug 27 2019, 12:21 PM

This quite annoying bug has also been reported here: T67295

-- (zgorg) added a subscriber: -- (zgorg).EditedSep 20 2019, 12:59 PM

yes very annoying. the only way I found it's to go in pycharm and reformat text. it happens to me often after copy of text I think. maybe from another text editor but not quite sure. and after this is invisible in Blender text editor no way to see where indentation error is. and even deleting all space/tab before each line and being sure to put tab at each line is not enough...the error is still there but invisible. at first this is because a space as been introduced like the error is reporting. difficult to explain and reproduce but work a script under text editor and soon or later the error will appears. apparently devs are not using this. maybe it would be more advanced https://blenderartists.org/t/how-would-you-show-some-love-for-the-blender-text-editor/1163857/107