-
-
Notifications
You must be signed in to change notification settings - Fork 271
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
Replace UnstableIO with IOContext{IO} #3735
Replace UnstableIO with IOContext{IO} #3735
Conversation
_io = Base.inferencebarrier(io) | ||
IOContext{IO}( | ||
_io, | ||
get(_io,:color,false) ? Base.ImmutableDict{Symbol,Any}(:color, true) : Base.ImmutableDict{Symbol,Any}() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have another suggestion as how one might construct a IOContext{IO}
?
julia> IOContext{IO}(stdout)
ERROR: MethodError: no method matching IOContext{IO}(::Base.TTY)
Closest candidates are:
IOContext{IO_t}(::IO_t, ::Base.ImmutableDict{Symbol, Any}) where IO_t<:IO
@ Base show.jl:291
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I understand. You need to call the inner constructor and the default for the dict is what is given here:
https://github.com/JuliaLang/julia/blob/b57f8d168dc88be8570e1c9ff7cd352fc5e11c98/base/show.jl#L303
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative is that I use Base.unwrapcontext
instead of copying the code. I'm not sure if that complicates the inference barrier or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does cause compilation of get
for the IO
though.
src/Pkg.jl
Outdated
struct UnstableIO <: IO | ||
io::IO | ||
# See discussion in https://github.com/JuliaLang/julia/pull/52249 | ||
const UnstableIO = IOContext{IO} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed I think? Or is it used somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few other references to UnstableIO
in Pkg.jl. I could get rid of the alias as its uses. Is that what you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed references to UnstableIO
in 9d57162
Looks like this has to be rebased to update for another use of
|
I will take a look, thanks. |
@KristofferC CI is now passing here. |
👍 |
(cherry picked from commit 195e17e)
While trying to send UnstableIO into Julia base, two suggestions arose:
Base.inferencebarrier
to prevent specialization:Fix Pkg.BinaryPlatforms invalidations by moving module to Base julia#52249 (comment)
IOContext{IO}
rather than introducing a new type:Fix Pkg.BinaryPlatforms invalidations by moving module to Base julia#52249 (comment)
Fix #3722 (
IOContext
hasclosewrite
)Addresses part of #3702 by removing
UnstableIO
and its associated invalidations.