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

Backports for 1.6-RC1 #39480

Merged
merged 3 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ const NonleafHandlingStyles = Union{DefaultArrayStyle,ArrayConflict}
# Now handle the remaining values
# The typeassert gives inference a helping hand on the element type and dimensionality
# (work-around for #28382)
ElType′ = ElType <: Type ? Type : ElType
ElType′ = ElType === Union{} ? Any : ElType <: Type ? Type : ElType
RT = dest isa AbstractArray ? AbstractArray{<:ElType′, ndims(dest)} : Any
return copyto_nonleaf!(dest, bc′, iter, state, 1)::RT
end
Expand Down
10 changes: 6 additions & 4 deletions base/regex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ function show(io::IO, re::Regex)
imsxa = PCRE.CASELESS|PCRE.MULTILINE|PCRE.DOTALL|PCRE.EXTENDED|PCRE.UCP
opts = re.compile_options
if (opts & ~imsxa) == (DEFAULT_COMPILER_OPTS & ~imsxa)
print(io, 'r')
print_quoted_literal(io, re.pattern)
print(io, "r\"")
escape_raw_string(io, re.pattern)
print(io, "\"")
if (opts & PCRE.CASELESS ) != 0; print(io, 'i'); end
if (opts & PCRE.MULTILINE) != 0; print(io, 'm'); end
if (opts & PCRE.DOTALL ) != 0; print(io, 's'); end
Expand Down Expand Up @@ -456,8 +457,9 @@ isvalid(s::SubstitutionString, i::Integer) = isvalid(s.string, i)::Bool
iterate(s::SubstitutionString, i::Integer...) = iterate(s.string, i...)::Union{Nothing,Tuple{AbstractChar,Int}}

function show(io::IO, s::SubstitutionString)
print(io, "s")
print_quoted_literal(io, s.string)
print(io, "s\"")
escape_raw_string(io, s.string)
print(io, "\"")
end

"""
Expand Down
10 changes: 0 additions & 10 deletions base/strings/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,6 @@ write(io::IO, s::Union{String,SubString{String}}) =
GC.@preserve s Int(unsafe_write(io, pointer(s), reinterpret(UInt, sizeof(s))))::Int
print(io::IO, s::Union{String,SubString{String}}) = (write(io, s); nothing)

## printing literal quoted string data ##

# this is the inverse of print_unescaped_chars(io, s, "\\\")

function print_quoted_literal(io, s::AbstractString)
print(io, '"')
for c = s; c == '"' ? print(io, "\\\"") : print(io, c); end
print(io, '"')
end

"""
repr(x; context=nothing)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
258aee97c44956a2ef94525b24899b66
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
882a552472b1023eed52ffbeeafd320a178dcb54f1dc36a5cc8c8c8f06c1038e13e8cd257784851532deaa3faaf9809146a0873c3dff28219b9ee6492366ee2c

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion stdlib/Downloads.version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
DOWNLOADS_BRANCH = master
DOWNLOADS_SHA1 = 4e55241413c95551c54fc5c9bfdf5f48cb02fc4c
DOWNLOADS_SHA1 = 0d798cfe2c06c304833dde913552fe13559a0c20
12 changes: 12 additions & 0 deletions test/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -990,3 +990,15 @@ p0 = copy(p)
@test isequal(identity.(Vector{<:Union{Int, Missing}}[[1, 2],[missing, 1]]),
[[1, 2],[missing, 1]])
end

@testset "Issue #28382: eltype inconsistent with getindex" begin
struct Cyclotomic <: Number
end

Base.eltype(::Type{<:Cyclotomic}) = Tuple{Int,Int}

Base.:*(c::T, x::Cyclotomic) where {T<:Real} = [1, 2]
Base.:*(x::Cyclotomic, c::T) where {T<:Real} = [1, 2]

@test Cyclotomic() .* [2, 3] == [[1, 2], [1, 2]]
end
20 changes: 10 additions & 10 deletions test/regex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@
@test map(m -> m.match, eachmatch(r"(\p{L}+)", "Tú lees.")) == ["Tú", "lees"]
@test map(m -> m.match, eachmatch(r"(\p{L}+)", "¿Cuál es tu pregunta?")) == ["Cuál", "es", "tu", "pregunta"]

# Issue 9545 (32 bit)
buf = PipeBuffer()
show(buf, r"")
@test read(buf, String) == "r\"\""

# see #10994, #11447: PCRE2 allows NUL chars in the pattern
@test occursin(Regex("^a\0b\$"), "a\0b")

Expand All @@ -52,12 +47,17 @@
subst = s"FROM: \g<name>\n MESSAGE: \1"
@test replace(msg, re => subst) == "FROM: Julia\n MESSAGE: Hello"

# Issue #9545 (32 bit)
@test repr(r"") == "r\"\""
# Issue #36550
@test repr(s"\x") == "s\"\\x\""
@test repr(s"\\x") == "s\"\\\\x\""
@test repr(s"\\\x") == "s\"\\\\\\x\""
@test repr(s"x\\") == "s\"x\\\""
@test repr(s"a\1b") == "s\"a\\1b\""
@test repr(s"\x") == raw"s\"\x\""
@test repr(s"\\x") == raw"s\"\\x\""
@test repr(s"\\\x") == raw"s\"\\\x\""
@test repr(s"x\\") == raw"s\"x\\\\\""
@test repr(s"a\1b") == raw"s\"a\1b\""
# Issue #29580
@test repr(r"\\\"") == raw"r\"\\\\\\\"\""
@test repr(s"\\\"\\") == raw"s\"\\\\\\\"\\\\\""

# findall
@test findall(r"\w+", "foo bar") == [1:3, 5:7]
Expand Down