forked from bartvdbraak/blender
console now shows unicode errors as well as errors caused by introspecting the api with autocompleate.
This commit is contained in:
parent
f8ecc3fd2f
commit
71d4c092ce
@ -85,7 +85,7 @@ def execute(context):
|
||||
sc = context.space_data
|
||||
|
||||
try:
|
||||
line = sc.history[-1].line
|
||||
line_object = sc.history[-1]
|
||||
except:
|
||||
return {'CANCELLED'}
|
||||
|
||||
@ -106,13 +106,22 @@ def execute(context):
|
||||
stdin_backup = sys.stdin
|
||||
sys.stdin = None
|
||||
|
||||
# run the console
|
||||
if not line.strip():
|
||||
line_exec = '\n' # executes a multiline statement
|
||||
else:
|
||||
line_exec = line
|
||||
# incase exception happens
|
||||
line = "" # incase of encodingf error
|
||||
is_multiline = False
|
||||
|
||||
is_multiline = console.push(line_exec)
|
||||
try:
|
||||
line = line_object.line
|
||||
|
||||
# run the console, "\n" executes a multiline statement
|
||||
line_exec = line if line.strip() else "\n"
|
||||
|
||||
is_multiline = console.push(line_exec)
|
||||
except:
|
||||
# unlikely, but this can happen with unicode errors for example.
|
||||
import traceback
|
||||
stderr.write(traceback.format_exc())
|
||||
|
||||
|
||||
stdout.seek(0)
|
||||
stderr.seek(0)
|
||||
@ -161,9 +170,6 @@ def autocomplete(context):
|
||||
|
||||
console = get_console(hash(context.region))[0]
|
||||
|
||||
current_line = sc.history[-1]
|
||||
line = current_line.line
|
||||
|
||||
if not console:
|
||||
return {'CANCELLED'}
|
||||
|
||||
@ -174,15 +180,27 @@ def autocomplete(context):
|
||||
# note: unlikely stdin would be used for autocomp. but its possible.
|
||||
stdin_backup = sys.stdin
|
||||
sys.stdin = None
|
||||
|
||||
scrollback = ""
|
||||
scrollback_error = ""
|
||||
|
||||
# This function isnt aware of the text editor or being an operator
|
||||
# just does the autocomp then copy its results back
|
||||
current_line.line, current_line.current_character, scrollback = \
|
||||
intellisense.expand(
|
||||
line=current_line.line,
|
||||
cursor=current_line.current_character,
|
||||
namespace=console.locals,
|
||||
private=bpy.app.debug)
|
||||
try:
|
||||
current_line = sc.history[-1]
|
||||
line = current_line.line
|
||||
|
||||
# This function isnt aware of the text editor or being an operator
|
||||
# just does the autocomp then copy its results back
|
||||
current_line.line, current_line.current_character, scrollback = \
|
||||
intellisense.expand(
|
||||
line=current_line.line,
|
||||
cursor=current_line.current_character,
|
||||
namespace=console.locals,
|
||||
private=bpy.app.debug)
|
||||
except:
|
||||
# unlikely, but this can happen with unicode errors for example.
|
||||
# or if the api attribute access its self causes an error.
|
||||
import traceback
|
||||
scrollback_error = traceback.format_exc()
|
||||
|
||||
# Separate automplete output by command prompts
|
||||
if scrollback != '':
|
||||
@ -194,6 +212,9 @@ def autocomplete(context):
|
||||
if scrollback:
|
||||
add_scrollback(scrollback, 'INFO')
|
||||
|
||||
if scrollback_error:
|
||||
add_scrollback(scrollback_error, 'ERROR')
|
||||
|
||||
# restore the stdin
|
||||
sys.stdin = stdin_backup
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user