Blender is unable to generate a complete error message when there is bad indentation in python code #67295

Closed
opened 2019-07-20 08:10:31 +02:00 by nBurn · 12 comments
Member

Blender Version
Broken: 2.80 RC2 (Win 64)
Worked: 2.79b (Win 64)

Short description of error
Blender's built in Python interpreter is not able to load part of the error message when an IndentationError is thrown in 2.80.

Exact steps for others to reproduce the error

  • Open Blender from a console,
  • Paste the script below into Blender's text editor and run it
import bpy

def foo():
print("hello")

foo()

Console output from 2.79

location: <unknown location>:-1
Error:   File "\Text", line 4
    print("hello")
        ^
IndentationError: expected an indented block

Console output from 2.80

AttributeError: 'IndentationError' object has no attribute 'msg'
Error: Python script failed, check the message in the system console
**Blender Version** Broken: 2.80 RC2 (Win 64) Worked: 2.79b (Win 64) **Short description of error** Blender's built in Python interpreter is not able to load part of the error message when an `IndentationError` is thrown in 2.80. **Exact steps for others to reproduce the error** - Open Blender from a console, - Paste the script below into Blender's text editor and run it ``` import bpy def foo(): print("hello") foo() ``` Console output from 2.79 ``` location: <unknown location>:-1 Error: File "\Text", line 4 print("hello") ^ IndentationError: expected an indented block ``` Console output from 2.80 ``` AttributeError: 'IndentationError' object has no attribute 'msg' Error: Python script failed, check the message in the system console
Author
Member

Added subscriber: @nBurn

Added subscriber: @nBurn

#65863 was marked as duplicate of this issue

#65863 was marked as duplicate of this issue

blender/blender#68512 was marked as duplicate of this issue

blender/blender#68512 was marked as duplicate of this issue
nBurn changed title from bpy is not including line number when there is bad indentation to bpy is not including a line number when there is bad indentation 2019-07-20 08:12:00 +02:00
nBurn changed title from bpy is not including a line number when there is bad indentation to Blender is unable to generate a complete error message when there is bad indentation in python code 2019-07-20 08:37:20 +02:00

Added subscribers: @ideasman42, @you.le

Added subscribers: @ideasman42, @you.le

I don't know if bpy_traceback.c changed, or if python was updated since 2.79b.

In bpy_traceback.c, void python_script_error_jump(...), there is this line:

if (exception && PyErr_GivenExceptionMatches(exception, PyExc_SyntaxError)) {

What is weird is that an Indentation error is considered as a Syntax error.

I'm wondering if instead we should write:

if (exception && PyErr_GivenExceptionMatches(exception, PyExc_NotImplementedError)) {

In this case, the errors messages seems to be displayed correctly.

But this needs to be reviewed by @ideasman42 . Furthermore, this doesn't solve the issue to not have the line number in the error if we have a "NonImplemented" error I guess.

python C 3 exception handling code: https://docs.python.org/3/c-api/exceptions.html

I don't know if bpy_traceback.c changed, or if python was updated since 2.79b. In bpy_traceback.c, void python_script_error_jump(...), there is this line: if (exception && PyErr_GivenExceptionMatches(exception, PyExc_SyntaxError)) { What is weird is that an Indentation error is considered as a Syntax error. I'm wondering if instead we should write: if (exception && PyErr_GivenExceptionMatches(exception, PyExc_NotImplementedError)) { In this case, the errors messages seems to be displayed correctly. But this needs to be reviewed by @ideasman42 . Furthermore, this doesn't solve the issue to not have the line number in the error if we have a "NonImplemented" error I guess. python C 3 exception handling code: https://docs.python.org/3/c-api/exceptions.html

Added subscriber: @mano-wii

Added subscriber: @mano-wii
Campbell Barton was assigned by Germano Cavalcante 2019-07-22 14:18:09 +02:00

It seems that this can even result in crash.

It seems that this can even result in crash.
Campbell Barton was unassigned by Dalai Felinto 2019-12-23 16:33:40 +01:00

Added subscribers: @mutantbob, @zgorg, @tintwotin, @snuq

Added subscribers: @mutantbob, @zgorg, @tintwotin, @snuq

Added subscriber: @iss

Added subscriber: @iss

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Richard Antalik self-assigned this 2020-01-07 19:23:13 +01:00

I can not reproduce this anymore.

I can not reproduce this anymore.

Added subscribers: @aroefer, @lichtwerk

Added subscribers: @aroefer, @lichtwerk
Sign in to join this conversation.
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#67295
No description provided.