Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-05-30 19:17:33 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-05-30 19:17:33 +0400
commit71d4c092ce4ee9c14639d44e560404727d365a6d (patch)
treeeb99b65437f4711f3c238dd6e01d458bd60d5e20
parentf8ecc3fd2fd11a40f5cea3a23b3c83b9861762cc (diff)
console now shows unicode errors as well as errors caused by introspecting the api with autocompleate.
-rw-r--r--release/scripts/op/console_python.py57
1 files changed, 39 insertions, 18 deletions
diff --git a/release/scripts/op/console_python.py b/release/scripts/op/console_python.py
index e2b046aae8c..1f0d9dbde60 100644
--- a/release/scripts/op/console_python.py
+++ b/release/scripts/op/console_python.py
@@ -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
+
+ try:
+ line = line_object.line
- is_multiline = console.push(line_exec)
+ # 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