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

RFC: move stringmime to Base64, rename reprmime -> repr #25990

Merged
merged 14 commits into from
Feb 17, 2018

Conversation

stevengj
Copy link
Member

@stevengj stevengj commented Feb 10, 2018

This PR makes three main changes:

  • It renames reprmime(mime, x) to repr(mime, x), analogous to how we merged writemime and show.

  • It moves stringmime to the Base64 package, since the only reason to use this function rather than repr is if you want base64 encoding for binary MIME types.

  • It adds optional context::Pair{Symbol}... arguments context keywords to repr to repr(mime, x) and stringmime, similar to c418a10 and sprint.

One slight wrinkle is that there is an ambiguity for repr(mime::Union{MIME,AbstractString}, p::Pair{Symbol}): are you asking for repr(mime) using the context p, or repr(p) using the MIME type mime? I opted to resolve this as repr(p) for mime::MIME and repr(mime) for mime::AbstractString.

To do:

  • Tests of the new context arguments
  • NEWS

@stevengj stevengj added the display and printing Aesthetics and correctness of printed representations of objects. label Feb 10, 2018
@stevengj
Copy link
Member Author

I am having a bootstrapping problem with moving stringmime to Base64, which means that the Markdown package now imports Base64:

LoadError("sysimg.jl", 514, LoadError("/Users/stevenj/Documents/Code/julia/usr/share/julia/site/v0.7/Test/src/Test.jl", 32, LoadError("/Users/stevenj/Documents/Code/julia/usr/share/julia/site/v0.7/InteractiveUtils/src/InteractiveUtils.jl", 16, LoadError("/Users/stevenj/Documents/Code/julia/usr/share/julia/site/v0.7/Markdown/src/Markdown.jl", 9, ArgumentError("Module Base64 not found in current path.\nRun `Pkg.add(\"Base64\")` to install the Base64 package.")))))

I don't understand why stdlib/Test can do using InteractiveUtils but stdlib/Markdown can't do using Base64. What am I missing?

@JeffBezanson
Copy link
Member

You need to add an entry for Base64 to Markdown's Project.toml file.

@stevengj
Copy link
Member Author

It looks like most of the calls to stringmime are for text/plain anyway, which means they can be replaced with repr calls.

@StefanKarpinski
Copy link
Member

The error messages for code loading are going to need a bit of work before we cut a final release. And documenting how all this stuff works will help, of course.

NEWS.md Outdated
@@ -33,7 +33,7 @@ New language features

* Added `⟂` (`\perp`) operator with comparison precedence ([#24404]).

* The `missing` singleton object (of type `Missing`) has been added to represent
* The `missing` singleton object (of type `Missing`) has been added to (repr)esent
Copy link
Member

Choose a reason for hiding this comment

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

😆

@stevengj
Copy link
Member Author

32-bit CI failures seem to be unrelated network problems.

@StefanKarpinski
Copy link
Member

I've started opening issues to track the known ongoing CI failures: ci Continuous integration . Shocking idea, I know.

@stevengj stevengj added the triage This should be discussed on a triage call label Feb 12, 2018
@JeffBezanson
Copy link
Member

I think we should resolve the ambiguity in repr by adding a context keyword argument (like sprint has).

@JeffBezanson
Copy link
Member

(The Pair arguments to repr were added very recently.)

@StefanKarpinski
Copy link
Member

You can replace repr(obj, pairs...) with repr(obj; context = ...) the way that sprint takes; alternatively, we could just replace the one usage of this with sprint(show, x, context = (:module => nothing)). There's one other usage of this but it's in Pkg3 and I'll know what to do when it breaks, so don't bother with a deprecation.

@StefanKarpinski StefanKarpinski removed the triage This should be discussed on a triage call label Feb 15, 2018
@StefanKarpinski StefanKarpinski added this to the 1.0 milestone Feb 15, 2018
@stevengj
Copy link
Member Author

stevengj commented Feb 16, 2018

Updated to a context keyword. I also added keyword documentation to sprint, and added a context keyword to base64encode.

@StefanKarpinski
Copy link
Member

This line's also going to have to change:

append!(Base.LOAD_PATH, $(repr(LOAD_PATH, :module => nothing)))

The simplest fix is changing it to

repr(LOAD_PATH, context = (:module => nothing))

@stevengj
Copy link
Member Author

Looks like the usual unrelated CI failures.

@JeffBezanson JeffBezanson merged commit 15a345b into JuliaLang:master Feb 17, 2018
@stevengj stevengj deleted the reprmime branch February 17, 2018 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
display and printing Aesthetics and correctness of printed representations of objects.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants