-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 bytestring with String #16453
Conversation
@@ -271,25 +271,25 @@ end | |||
|
|||
immutable LatexCompletions <: CompletionProvider; end | |||
|
|||
bytestring_beforecursor(buf::IOBuffer) = bytestring(buf.data[1:buf.ptr-1]) | |||
String_beforecursor(buf::IOBuffer) = String(buf.data[1:buf.ptr-1]) |
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.
Looks like automated replacement could use some human thinking here. :-)
Shouldn't we keep a deprecated version of |
That this is a WIP PR? |
c3fdc94
to
96c36e6
Compare
|
||
function bytestring(p::Union{Ptr{UInt8},Ptr{Int8}},len::Integer) | ||
Create a string from the address of a C (0-terminated) string encoded as UTF-8. | ||
A copy is made so the ptr can be safely freed. If `length` is specified, the string |
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.
spell out pointer?
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 is cut-and-pasted from the original docs. Rewriting them is another issue.
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.
Ah. Did not notice that because deleting the old copy isn't in the diff yet. (maybe it was and I just didn't search for what I thought I did)
It's on the list at #16107, but these should probably have NEWS entries as you go. Some remaining occurrences outside of base:
|
96c36e6
to
24efdf7
Compare
Thanks, @tkelman. I'm going to write NEWS when the changes are done. |
@@ -238,7 +238,7 @@ | |||
<string>broadcast_setindex!</string> | |||
<string>bswap</string> | |||
<string>bytes2hex</string> | |||
<string>bytestring</string> | |||
<string>String</string> |
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.
already present in a separate list of types later in the file. if it weren't, would be nice to keep this file sorted
24efdf7
to
230e767
Compare
Is this the cause of the new failure in genstdlib? It looks like there's also a pending update for one of the definitions in stdlib/string.rst
|
067ff81 - though I'm going to take a look at some of the things sphinx is complaining about and make more of a branch out of it |
Wrap a vector of bytes encoding string data as UTF-8 in a `String` object. | ||
The resulting `String` object takes ownership of the array. | ||
""" | ||
String(s::Vector{UInt8}) = |
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 gives a method overwrite warning with the inner constructor from base/boot.jl
, but removing this method seems to make the "read" test segfault.
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.
That's because one of the calls to String(bytes)
in datafmt.jl should have been String(copy(bytes))
... I have a patch forthcoming.
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.
Fixed in #16731.
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.
Thanks, @stevengj.
Does this need something else in Compat.jl? Just doing |
Yeah, looks like we need a definition like String(ptr::Ptr, len) = bytestring(ptr, len) since we didn't have |
Part of #16107.