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

Add trailing nl for display(::TextDisplay, ...) #43787

Merged
merged 3 commits into from
Jan 13, 2022

Conversation

t-bltg
Copy link
Contributor

@t-bltg t-bltg commented Jan 12, 2022

Fix #43766.

Test pass locally on 1.6.5 and 1.7.1 builds on linux, let's check CI now ...

It'd be great (if possible) to have this land in 1.6 and 1.7.

@t-bltg t-bltg changed the title Add trailing nl for display(::TextDisplay, ...) Add trailing nl for display(::TextDisplay, ...) Jan 12, 2022
base/client.jl Show resolved Hide resolved
@mkitti
Copy link
Contributor

mkitti commented Jan 13, 2022

Test Failed at /usr/home/julia/buildbot/w2_tester/tester_freebsd64/build/share/julia/stdlib/v1.8/DelimitedFiles/test/runtests.jl:327
  Expression: String(take!(d.io)) == "3,1,4\n"
   Evaluated: "3,1,4\n\n" == "3,1,4\n"

@t-bltg
Copy link
Contributor Author

t-bltg commented Jan 13, 2022

Thanks, I forgot to test the stdlib modules (only Base), will fix that asap.

@t-bltg t-bltg marked this pull request as draft January 13, 2022 09:04
@t-bltg
Copy link
Contributor Author

t-bltg commented Jan 13, 2022

Looks like the CI failure is caused by #43059.

Must wait for #43790 to be merged.

@t-bltg t-bltg marked this pull request as ready for review January 13, 2022 21:03
@JeffBezanson JeffBezanson merged commit 49f4f78 into JuliaLang:master Jan 13, 2022
@t-bltg t-bltg deleted the display_nl branch January 13, 2022 21:47
nickrobinson251 pushed a commit to nickrobinson251/julia that referenced this pull request Jan 14, 2022
nickrobinson251 pushed a commit to nickrobinson251/julia that referenced this pull request Jan 14, 2022
@t-bltg t-bltg mentioned this pull request Jan 14, 2022
50 tasks
@xitology
Copy link
Contributor

The change itself may be reasonable, but it's going to break all the code that uses display for output.

@mkitti
Copy link
Contributor

mkitti commented Jan 16, 2022

The change itself may be reasonable, but it's going to break all the code that uses display for output.

I would be interested in learning more about code that uses display for output using TextDisplay. Do you have examples?

@xitology
Copy link
Contributor

I use display all the time in command-line scripts to print multi-line data. I have to add an extra println() after each display() call, which I admit is irritating.

Here is my package where this change broke the test suite:
https://github.com/MechanicalRabbit/NarrativeTest.jl/runs/4831849293?check_suite_focus=true
The specific line in the package that calls display:
https://github.com/MechanicalRabbit/NarrativeTest.jl/blob/master/src/NarrativeTest.jl#L380

@t-bltg
Copy link
Contributor Author

t-bltg commented Jan 16, 2022

I use display all the time in command-line scripts to print multi-line data. I have to add an extra println() after each display() call, which I admit is irritating.

I guess you should use show instead of display.

@xitology
Copy link
Contributor

I use display all the time in command-line scripts to print multi-line data. I have to add an extra println() after each display() call, which I admit is irritating.

I guess you should use show instead of display.

show(stdout, "text/plain", x) is a bit mouthful compared with display(x).

@t-bltg
Copy link
Contributor Author

t-bltg commented Jan 16, 2022

IMO having a consistent behavior for display using either TextDisplay or REPLDisplay (as was the motivation of this PR (see #43766)) is the right move.

Isn't show(stdout, x) sufficient in your case ?

@xitology
Copy link
Contributor

IMO having a consistent behavior for display using either TextDisplay or REPLDisplay (as was the motivation of this PR) is the right move.

Isn't show(stdout, x) sufficient in your case ?

It gives a different output:

julia> show(stdout, [1,2,3])
[1, 2, 3]
julia> show(stdout, "text/plain", [1,2,3])
3-element Vector{Int64}:
 1
 2
 3
julia> display([1,2,3])
3-element Vector{Int64}:
 1
 2
 3

julia> show(stdout, Dict("key" => "value"))
Dict("key" => "value")
julia> show(stdout, "text/plain", Dict("key" => "value"))
Dict{String, String} with 1 entry:
  "key" => "value"
julia> display(Dict("key" => "value"))
Dict{String, String} with 1 entry:
  "key" => "value"

@t-bltg
Copy link
Contributor Author

t-bltg commented Jan 16, 2022

I agree that it is painful to fix these things. But defining disp(x) = show(stdout, "text/plain", x) in your CI test scripts is always possible if you want to avoid using show(stdout, "text/plain", x) and make the tests pass on nightly and e.g. 1.6.5 or 1.7.2.

@xitology
Copy link
Contributor

My point is that it is not a bugfix but a breaking change and should be treated as such.

xitology added a commit to MechanicalRabbit/NarrativeTest.jl that referenced this pull request Jan 16, 2022
@t-bltg
Copy link
Contributor Author

t-bltg commented Jan 16, 2022

My point is that it is not a bugfix but a breaking change and should be treated as such.

I'd say it's debatable whether it is a bug fix or a breaking change.

@mkitti
Copy link
Contributor

mkitti commented Jan 16, 2022

Perhaps we should add something in Compat.jl?

LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Feb 22, 2022
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Mar 8, 2022
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.

Display linebreaks, TextDisplay vs REPLDisplay
4 participants