Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workaround wrong paths reported for stdlib functions #32763

Merged
merged 3 commits into from
Oct 23, 2019

Conversation

KristofferC
Copy link
Sponsor Member

@KristofferC KristofferC commented Aug 2, 2019

Not really clean to special case it just ofr less and edit but that is where people seems to encounter this issue the most. The workaround could potentially be put in find_source_file but that is a bit more "invasive".

This is also kinda hard to test. I tested it by evaluating this into InteractveUtils in a released julia.

Fixes #26314

@fredrikekre
Copy link
Member

Maybe add this for @which too?

@timholy timholy mentioned this pull request Aug 24, 2019
@cossio
Copy link
Contributor

cossio commented Oct 14, 2019

Something holding this from being merged? Would be nice to have this issue fixed.

@KristofferC KristofferC force-pushed the kc/stdlib_path_less branch 2 times, most recently from 758a381 to 8bd5da3 Compare October 14, 2019 19:28
@KristofferC KristofferC force-pushed the kc/stdlib_path_less branch 3 times, most recently from 2cda8ba to 748d69c Compare October 14, 2019 20:06
@KristofferC KristofferC changed the title workaround wrong paths reported for stdlib functions in less and edit workaround wrong paths reported for stdlib functions Oct 14, 2019
@KristofferC
Copy link
Sponsor Member Author

Something holding this from being merged? Would be nice to have this issue fixed.

I improved the implementation a bit but should be good to go now.

Tried it locally with the executable built by the buildbot and @which, @edit and @less work well with stdlib functions now.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Oct 15, 2019

Yeah, going with something, anything, is better than being always broken.

# This function does the method location updating
function updated_methodloc(m)
file, line = invokelatest(methodloc_callback[], m)
if file !== nothing && isdefined(@__MODULE__, :Sys)
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if file !== nothing && isdefined(@__MODULE__, :Sys)
if file !== nothing && Sys.BUILD_STDLIB_PATH != Sys.STDLIB

Is Sys ever not defined?

And should we put this inside default_methodloc, or do we want to do this unconditionally?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not defined when this function gets defined and I was worried if there was some error before Sys gets defined then it would crash when trying to print some method.

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to do this unconditionally.

@@ -248,7 +258,7 @@ function show_method_table(io::IO, ms::MethodList, max::Int=-1, header::Bool=tru
show(io, meth; kwtype=kwtype)
file, line = meth.file, meth.line
try
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move these try; catch inside updated_methodloc also

# BUILD_STDLIB_PATH gets defined in sysinfo.jl
file = replace(String(file), normpath(Sys.BUILD_STDLIB_PATH) => normpath(Sys.STDLIB))
end
return Symbol(file), line
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return Symbol(file), line
return string(file), line

@@ -118,6 +118,16 @@ end
default_methodloc(method::Method) = method.file, method.line
const methodloc_callback = Ref{Function}(default_methodloc)

# This function does the method location updating
function updated_methodloc(m)
file, line = invokelatest(methodloc_callback[], m)
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
file, line = invokelatest(methodloc_callback[], m)
file, line = try
invokelatest(methodloc_callback[], m)
catch
default_methodloc(m)
end
file === nothing && return (string(m.file), m.line)
file = string(file)

@@ -118,6 +118,16 @@ end
default_methodloc(method::Method) = method.file, method.line
const methodloc_callback = Ref{Function}(default_methodloc)

# This function does the method location updating
function updated_methodloc(m)
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function updated_methodloc(m)
function updated_methodloc(m)::Tuple{String, Int32}

@rapus95
Copy link
Contributor

rapus95 commented Oct 16, 2019

Can this still make it into 1.3 or does the feature freeze prohibit it?

@KristofferC
Copy link
Sponsor Member Author

It will not make it into 1.3.0 for sure. Maybe 1.3.1.

@rapus95
Copy link
Contributor

rapus95 commented Oct 16, 2019

Btw as this request is called workaround, I guess you'd not call it the idiomatic way.
Would it generally make sense to use the pathof(module) function to determine the path of the module where the function was defined and then resolve the path relative to that?

@KristofferC KristofferC force-pushed the kc/stdlib_path_less branch 2 times, most recently from 29dac94 to cf492f1 Compare October 16, 2019 10:00
@KristofferC
Copy link
Sponsor Member Author

Btw as this request is called workaround, I guess you'd not call it the idiomatic way.

I dunno... If it works, it works:P

I did some fixups here @vtjnash

base/methodshow.jl Outdated Show resolved Hide resolved
@musm
Copy link
Contributor

musm commented Oct 16, 2019

Does Pkg\src\Operations.jl need an update as well?
I get the wrong paths as well when interacting with the Package Manager.

└ @ Pkg.Operations C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\Pkg\src\Operations.jl:494

@KristofferC
Copy link
Sponsor Member Author

I guess @info embeds the full path as well at macro expansion time. But that's for another PR.

@KristofferC KristofferC merged commit f9975d1 into master Oct 23, 2019
@KristofferC KristofferC deleted the kc/stdlib_path_less branch October 23, 2019 09:37
@rapus95
Copy link
Contributor

rapus95 commented Oct 23, 2019

Sad that it won't make it into 1.3 even though it is already merged 🙈

@KristofferC
Copy link
Sponsor Member Author

Could be put into 1.3.1 if it doesnt cause any problems on master.

@carstenbauer
Copy link
Member

Could be put into 1.3.1 if it doesnt cause any problems on master.

I'm begging for it! This has been bugging me for way too long now. 😊

@fredrikekre fredrikekre added backport 1.3 status:triage This should be discussed on a triage call labels Nov 26, 2019
@KristofferC
Copy link
Sponsor Member Author

I have my script set to ignore backport labels that also has a triage label because we said we would triage backports at some point. This doesn't seem to happen though so the result is that PRs (like this) just get forgotten. I'll just backport stuff that includes the triage label as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

edit and less fail for stdlib functions in distribution binaries
7 participants