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

ascii: only support checking String for pure ASCIIness #16396

Merged
merged 2 commits into from
May 18, 2016

Conversation

StefanKarpinski
Copy link
Member

Part of #16107.

@StefanKarpinski StefanKarpinski mentioned this pull request May 16, 2016
32 tasks

function ascii(s::String)
for b in s.data
b < 0x80 || throw(ArgumentError("invalid ASCII sequence"))
Copy link
Contributor

Choose a reason for hiding this comment

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

should we show the string?

Copy link
Member

Choose a reason for hiding this comment

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

+1, show the position where the invalid char was found and print it.

@tkelman
Copy link
Contributor

tkelman commented May 17, 2016

should add a test that it throws on non-ascii input (unless we already have one that I can't find?), and docstrings need updating

@StefanKarpinski
Copy link
Member Author

What's up with the test failure on AppVeyor? It looks like it succeeded and then hung.

@@ -8719,29 +8719,14 @@ alias the input `x` to modify it in-place.
filt!

"""
ascii(::Array{UInt8,1})
ascii(s::AbstractString)
Copy link
Contributor

Choose a reason for hiding this comment

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

make corresponding change in rst too

Copy link
Contributor

Choose a reason for hiding this comment

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

would be good to migrate the remaining docstring inline

Copy link
Member Author

Choose a reason for hiding this comment

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

Doesn't that get automatically done when the RST gets regenerated?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is what the script uses to find the correct place to insert the docstring so changing the signature will make the doc generation fail.

Copy link
Member Author

Choose a reason for hiding this comment

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

The signatures now match...

Copy link
Contributor

Choose a reason for hiding this comment

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

By inline I mean moving the markdown docstring to the source, so we can gradually get rid of this Base.jl file.

Copy link
Contributor

Choose a reason for hiding this comment

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

You also should have run genstdlib and committed that at the same time, otherwise unrelated doc changes are ending up in multiple other PR's.

@StefanKarpinski
Copy link
Member Author

Any thoughts on whether I should merge this now and do additional work in a new PR or just add commits here? By additional work, I mean more parts of the replace utf8, bytestring, etc. with String bullet in #16107.


function ascii(s::String)
for (i, b) in enumerate(s.data)
b < 0x80 || throw(ArgumentError("invalid ASCII at index $i in $(repr(s))"))
Copy link
Contributor

Choose a reason for hiding this comment

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

do we have or want a more specific exception type than ArgumentError for this? I guess we have UnicodeError but are you planning on removing that?

@tkelman
Copy link
Contributor

tkelman commented May 17, 2016

I like the idea of keeping them small and separate if possible. Easier to review in smaller pieces.

@StefanKarpinski StefanKarpinski changed the title WIP: replace utf8, bytestring, etc. with String ascii: only support checking String for pure ASCIIness May 18, 2016
@StefanKarpinski StefanKarpinski merged commit 778740e into master May 18, 2016
@StefanKarpinski StefanKarpinski deleted the sk/highlander2 branch May 18, 2016 11:17
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.

4 participants