提交 ea7f5086 编写于 作者: A Aaron Patterson

delay backtrace scrubbing until we actually raise an exception. fixes #1936

上级 cea06a8e
......@@ -478,10 +478,6 @@ def load_missing_constant(from_mod, const_name)
qualified_name = qualified_name_for from_mod, const_name
path_suffix = qualified_name.underscore
trace = caller.reject {|l| l.starts_with? __FILE__ }
name_error = NameError.new("uninitialized constant #{qualified_name}")
name_error.set_backtrace(trace)
file_path = search_for_file(path_suffix)
if file_path && ! loaded.include?(File.expand_path(file_path)) # We found a matching file to load
......@@ -500,11 +496,12 @@ def load_missing_constant(from_mod, const_name)
return parent.const_missing(const_name)
rescue NameError => e
raise unless e.missing_name? qualified_name_for(parent, const_name)
raise name_error
end
else
raise name_error
end
raise NameError,
"uninitialized constant #{qualified_name}",
caller.reject {|l| l.starts_with? __FILE__ }
end
# Remove the constants that have been autoloaded, and those that have been
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册