@@ -1998,7 +1998,6 @@ public static void PrintExpressionValue(CodeContext/*!*/ context, object value)
19981998 pc . CallWithContext ( context , dispHook , value ) ;
19991999 }
20002000
2001- #if FEATURE_FULL_CONSOLE
20022001 internal static void PrintException ( CodeContext /*!*/ context , Exception /*!*/ exception , object ? console = null ) {
20032002 PythonContext pc = context . LanguageContext ;
20042003 PythonTuple exInfo = GetExceptionInfoLocal ( context , exception ) ;
@@ -2008,14 +2007,18 @@ internal static void PrintException(CodeContext/*!*/ context, Exception/*!*/ exc
20082007
20092008 object exceptHook = pc . GetSystemStateValue ( "excepthook" ) ;
20102009 if ( exceptHook is BuiltinFunction bf && bf . DeclaringType == typeof ( SysModule ) && bf . Name == "excepthook" ) {
2011- // builtin except hook, display it to the console which may do nice coloring
2010+ // builtin except hook
2011+ #if FEATURE_FULL_CONSOLE
20122012 if ( console is IConsole con ) {
2013+ // display it to the console which may do nice coloring
20132014 con . WriteLine ( pc . FormatException ( exception ) , Style . Error ) ;
2014- } else {
2015+ } else
2016+ #endif
2017+ {
20152018 PrintWithDest ( context , pc . SystemStandardError , pc . FormatException ( exception ) ) ;
20162019 }
20172020 } else {
2018- // user defined except hook or no console
2021+ // user defined except hook
20192022 try {
20202023 PythonCalls . Call ( context , exceptHook , exInfo [ 0 ] , exInfo [ 1 ] , exInfo [ 2 ] ) ;
20212024 } catch ( Exception e ) {
@@ -2028,7 +2031,6 @@ internal static void PrintException(CodeContext/*!*/ context, Exception/*!*/ exc
20282031 }
20292032 }
20302033 }
2031- #endif
20322034
20332035 #endregion
20342036
0 commit comments