@@ -367,6 +367,13 @@ function showerror_nostdio(err, msg::AbstractString)
367
367
ccall (:jl_printf , Cint, (Ptr{Cvoid},Cstring), stderr_stream, " \n " )
368
368
end
369
369
370
+ stacktrace_expand_basepaths ():: Bool =
371
+ tryparse (Bool, get (ENV , " JULIA_STACKTRACE_EXPAND_BASEPATHS" , " false" )) === true
372
+ stacktrace_contract_userdir ():: Bool =
373
+ tryparse (Bool, get (ENV , " JULIA_STACKTRACE_CONTRACT_HOMEDIR" , " true" )) === true
374
+ stacktrace_linebreaks ():: Bool =
375
+ tryparse (Bool, get (ENV , " JULIA_STACKTRACE_LINEBREAKS" , " false" )) === true
376
+
370
377
function show_method_candidates (io:: IO , ex:: MethodError , @nospecialize kwargs= ())
371
378
is_arg_types = isa (ex. args, DataType)
372
379
arg_types = is_arg_types ? ex. args : typesof (ex. args... )
@@ -494,7 +501,12 @@ function show_method_candidates(io::IO, ex::MethodError, @nospecialize kwargs=()
494
501
end
495
502
print (iob, " )" )
496
503
show_method_params (iob0, tv)
497
- print (iob, " at " , method. file, " :" , method. line)
504
+ file, line = functionloc (method)
505
+ if file === nothing
506
+ file = string (method. file)
507
+ end
508
+ stacktrace_contract_userdir () && (file = contractuser (file))
509
+ print (iob, " at " , file, " :" , line)
498
510
if ! isempty (kwargs):: Bool
499
511
unexpected = Symbol[]
500
512
if isempty (kwords) || ! (any (endswith (string (kword), " ..." ) for kword in kwords))
@@ -554,13 +566,6 @@ const update_stackframes_callback = Ref{Function}(identity)
554
566
const STACKTRACE_MODULECOLORS = [:magenta , :cyan , :green , :yellow ]
555
567
const STACKTRACE_FIXEDCOLORS = IdDict (Base => :light_black , Core => :light_black )
556
568
557
- stacktrace_expand_basepaths ():: Bool =
558
- tryparse (Bool, get (ENV , " JULIA_STACKTRACE_EXPAND_BASEPATHS" , " false" )) === true
559
- stacktrace_contract_userdir ():: Bool =
560
- tryparse (Bool, get (ENV , " JULIA_STACKTRACE_CONTRACT_HOMEDIR" , " true" )) === true
561
- stacktrace_linebreaks ():: Bool =
562
- tryparse (Bool, get (ENV , " JULIA_STACKTRACE_LINEBREAKS" , " false" )) === true
563
-
564
569
function show_full_backtrace (io:: IO , trace:: Vector ; print_linebreaks:: Bool )
565
570
num_frames = length (trace)
566
571
ndigits_max = ndigits (num_frames)
689
694
# Print a stack frame where the module color is set manually with `modulecolor`.
690
695
function print_stackframe (io, i, frame:: StackFrame , n:: Int , digit_align_width, modulecolor)
691
696
file, line = string (frame. file), frame. line
697
+ file = fixup_stdlib_path (file)
692
698
stacktrace_expand_basepaths () && (file = something (find_source_file (file), file))
693
699
stacktrace_contract_userdir () && (file = contractuser (file))
694
700
0 commit comments