@@ -362,6 +362,13 @@ function showerror_nostdio(err, msg::AbstractString)
362362 ccall (:jl_printf , Cint, (Ptr{Cvoid},Cstring), stderr_stream, " \n " )
363363end
364364
365+ stacktrace_expand_basepaths ():: Bool =
366+ tryparse (Bool, get (ENV , " JULIA_STACKTRACE_EXPAND_BASEPATHS" , " false" )) === true
367+ stacktrace_contract_userdir ():: Bool =
368+ tryparse (Bool, get (ENV , " JULIA_STACKTRACE_CONTRACT_HOMEDIR" , " true" )) === true
369+ stacktrace_linebreaks ():: Bool =
370+ tryparse (Bool, get (ENV , " JULIA_STACKTRACE_LINEBREAKS" , " false" )) === true
371+
365372function show_method_candidates (io:: IO , ex:: MethodError , @nospecialize kwargs= ())
366373 is_arg_types = isa (ex. args, DataType)
367374 arg_types = is_arg_types ? ex. args : typesof (ex. args... )
@@ -489,7 +496,12 @@ function show_method_candidates(io::IO, ex::MethodError, @nospecialize kwargs=()
489496 end
490497 print (iob, " )" )
491498 show_method_params (iob0, tv)
492- print (iob, " at " , method. file, " :" , method. line)
499+ file, line = functionloc (method)
500+ if file === nothing
501+ file = string (method. file)
502+ end
503+ stacktrace_contract_userdir () && (file = contractuser (file))
504+ print (iob, " at " , file, " :" , line)
493505 if ! isempty (kwargs):: Bool
494506 unexpected = Symbol[]
495507 if isempty (kwords) || ! (any (endswith (string (kword), " ..." ) for kword in kwords))
@@ -549,13 +561,6 @@ const update_stackframes_callback = Ref{Function}(identity)
549561const STACKTRACE_MODULECOLORS = [:magenta , :cyan , :green , :yellow ]
550562const STACKTRACE_FIXEDCOLORS = IdDict (Base => :light_black , Core => :light_black )
551563
552- stacktrace_expand_basepaths ():: Bool =
553- tryparse (Bool, get (ENV , " JULIA_STACKTRACE_EXPAND_BASEPATHS" , " false" )) === true
554- stacktrace_contract_userdir ():: Bool =
555- tryparse (Bool, get (ENV , " JULIA_STACKTRACE_CONTRACT_HOMEDIR" , " true" )) === true
556- stacktrace_linebreaks ():: Bool =
557- tryparse (Bool, get (ENV , " JULIA_STACKTRACE_LINEBREAKS" , " false" )) === true
558-
559564function show_full_backtrace (io:: IO , trace:: Vector ; print_linebreaks:: Bool )
560565 num_frames = length (trace)
561566 ndigits_max = ndigits (num_frames)
684689# Print a stack frame where the module color is set manually with `modulecolor`.
685690function print_stackframe (io, i, frame:: StackFrame , n:: Int , digit_align_width, modulecolor)
686691 file, line = string (frame. file), frame. line
692+ file = fixup_stdlib_path (file)
687693 stacktrace_expand_basepaths () && (file = something (find_source_file (file), file))
688694 stacktrace_contract_userdir () && (file = contractuser (file))
689695
0 commit comments