Skip to content

Commit

Permalink
Merge c0b1a0c into ef4fe83
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC authored May 10, 2020
2 parents ef4fe83 + c0b1a0c commit 58353fd
Show file tree
Hide file tree
Showing 28 changed files with 175 additions and 129 deletions.
2 changes: 1 addition & 1 deletion base/pcre.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ free_match_context(context) =
function err_message(errno)
buffer = Vector{UInt8}(undef, 256)
ccall((:pcre2_get_error_message_8, PCRE_LIB), Cvoid,
(Int32, Ptr{UInt8}, Csize_t), errno, buffer, sizeof(buffer))
(UInt32, Ptr{UInt8}, Csize_t), errno, buffer, sizeof(buffer))
GC.@preserve buffer unsafe_string(pointer(buffer))
end

Expand Down
34 changes: 15 additions & 19 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1207,13 +1207,7 @@ function show_unquoted_expr_fallback(io::IO, ex::Expr, indent::Int, quote_level:
show(io, ex.head)
for arg in ex.args
print(io, ", ")
if isa(arg, Expr)
print(io, ":(")
show_unquoted(io, arg, indent, 0, quote_level+1)
print(io, ")")
else
show(io, arg)
end
show(io, arg)
end
print(io, "))")
end
Expand Down Expand Up @@ -1603,17 +1597,19 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In

elseif head === :quote && nargs == 1 && isa(args[1], Symbol)
show_unquoted_quote_expr(IOContext(io, beginsym=>false), args[1]::Symbol, indent, 0, quote_level+1)
elseif head === :quote && nargs == 1 && is_expr(args[1], :block)
show_block(IOContext(io, beginsym=>false), "quote", Expr(:quote, args[1].args...), indent,
quote_level+1)
print(io, "end")
elseif head === :quote && nargs == 1
print(io, ":(")
show_unquoted(IOContext(io, beginsym=>false), args[1], indent+2, 0, quote_level+1)
print(io, ")")
elseif head === :quote
show_block(IOContext(io, beginsym=>false), "quote", ex, indent, quote_level+1)
print(io, "end")
elseif head === :quote && !get(io, :unquote_fallback, true)
if nargs == 1 && is_expr(args[1], :block)
show_block(IOContext(io, beginsym=>false), "quote", Expr(:quote, args[1].args...), indent,
quote_level+1)
print(io, "end")
elseif nargs == 1
print(io, ":(")
show_unquoted(IOContext(io, beginsym=>false), args[1], indent+2, 0, quote_level+1)
print(io, ")")
else
show_block(IOContext(io, beginsym=>false), "quote", ex, indent, quote_level+1)
print(io, "end")
end

elseif head === :gotoifnot && nargs == 2 && isa(args[2], Int)
print(io, "unless ")
Expand Down Expand Up @@ -1648,7 +1644,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
if head === :$
quote_level -= 1
end
if head === :$ && quote_level < 0 && get(io, :unquote_fallback, true)
if head === :$ && get(io, :unquote_fallback, true)
unhandled = true
else
print(io, head)
Expand Down
7 changes: 4 additions & 3 deletions base/stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ abstract type LibuvStream <: IO end
# . +- Pipe
# . +- Process (not exported)
# . +- ProcessChain (not exported)
# +- BufferStream
# +- DevNull (not exported)
# +- Filesystem.File
# +- LibuvStream (not exported)
# . +- PipeEndpoint (not exported)
# . +- TCPSocket
# . +- TTY (not exported)
# . +- UDPSocket
# . +- BufferStream (FIXME: 2.0)
# +- IOBuffer = Base.GenericIOBuffer{Array{UInt8,1}}
# +- IOStream

Expand Down Expand Up @@ -497,7 +497,7 @@ get(::TTY, key::Symbol, default) = key === :color ? have_color : default
function alloc_request(buffer::IOBuffer, recommended_size::UInt)
ensureroom(buffer, Int(recommended_size))
ptr = buffer.append ? buffer.size + 1 : buffer.ptr
nb = length(buffer.data) - ptr + 1
nb = min(length(buffer.data), buffer.maxsize) - ptr + 1
return (pointer(buffer.data, ptr), nb)
end

Expand Down Expand Up @@ -1207,11 +1207,12 @@ end
mutable struct BufferStream <: LibuvStream
buffer::IOBuffer
cond::Threads.Condition
readerror::Any
is_open::Bool
buffer_writes::Bool
lock::ReentrantLock # advisory lock

BufferStream() = new(PipeBuffer(), Threads.Condition(), true, false, ReentrantLock())
BufferStream() = new(PipeBuffer(), Threads.Condition(), nothing, true, false, ReentrantLock())
end

isopen(s::BufferStream) = s.is_open
Expand Down
1 change: 1 addition & 0 deletions base/strings/substring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ end

function repeat(s::Union{String, SubString{String}}, r::Integer)
r < 0 && throw(ArgumentError("can't repeat a string $r times"))
r == 0 && return ""
r == 1 && return String(s)
n = sizeof(s)
out = _string_n(n*r)
Expand Down
14 changes: 14 additions & 0 deletions contrib/mac/app/Entitlements.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,19 @@
<dict>
<key>com.apple.security.automation.apple-events</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.debugger</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.device.camera</key>
<true/>
</dict>
</plist>
9 changes: 7 additions & 2 deletions contrib/mac/app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ dmg/$(APP_NAME): startup.applescript julia.icns
tar zxf $(JULIAHOME)/$(JULIA_BINARYDIST_FILENAME).tar.gz -C $@/Contents/Resources/julia --strip-components 1
if [ -n "$$MACOS_CODESIGN_IDENTITY" ]; then \
echo "Codesigning with identity $$MACOS_CODESIGN_IDENTITY"; \
codesign -s "$$MACOS_CODESIGN_IDENTITY" --option=runtime --entitlements Entitlements.plist -v --deep $@; \
MACHO_FILES=$$(find "$@" -type f -perm -755 | cut -d: -f1); \
for f in $${MACHO_FILES}; do \
echo "Codesigning $${f}..."; \
codesign -s "$$MACOS_CODESIGN_IDENTITY" --option=runtime --entitlements Entitlements.plist -vvv --timestamp --deep --force "$${f}"; \
done; \
codesign -s "$$MACOS_CODESIGN_IDENTITY" --option=runtime --entitlements Entitlements.plist -vvv --timestamp --deep --force "$@"; \
else \
true; \
fi
Expand All @@ -62,7 +67,7 @@ ifneq ($(filter root,$(ROOTFILES)),)
@echo "We have to use sudo here to clean out folders owned by root. You may be asked for your password"
sudo rm -rf dmg *.dmg notarize-*.xml
else
rm -rf dmg *.dmg
rm -rf dmg *.dmg notarize-*.xml
endif

notarize-upload-$(DMG_NAME).xml: $(DMG_NAME)
Expand Down
4 changes: 4 additions & 0 deletions contrib/mac/app/notarize_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ function wait_until_completed()
echo -n "."
sleep 10
continue
elif [[ ${STATUS} == "invalid" ]]; then
echo "invalid! Looks like something got borked:"
/usr/libexec/PlistBuddy -c "print notarization-info:LogFileURL" "${PLIST_FILE}" 2>/dev/null
exit 1
else
echo "Notarization failed with status ${STATUS}"
exit 1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c43b575438cdffd34c51ef6953d28337
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
91a72184a80c5856390cd2879ff29dad1583db7c1657c7b9d9b1d67b6c5c465319ee85052d358471d2de9d311da50989fa848cb47730e59da769a224286655da

This file was deleted.

This file was deleted.

16 changes: 8 additions & 8 deletions doc/src/manual/metaprogramming.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ julia> x = :(1 + 2);
julia> e = quote quote $x end end
quote
#= none:1 =#
quote
#= none:1 =#
$x
end
$(Expr(:quote, quote
#= none:1 =#
$(Expr(:$, :x))
end))
end
```

Expand All @@ -289,10 +289,10 @@ This is done with multiple `$`s:
julia> e = quote quote $$x end end
quote
#= none:1 =#
quote
#= none:1 =#
$(1 + 2)
end
$(Expr(:quote, quote
#= none:1 =#
$(Expr(:$, :(1 + 2)))
end))
end
```

Expand Down
2 changes: 1 addition & 1 deletion src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ static jl_value_t *scm_to_julia_(fl_context_t *fl_ctx, value_t e, jl_module_t *m
assert(jl_is_symbol(ex));
temp = jl_module_globalref(jl_core_module, (jl_sym_t*)ex);
}
else if (sym == inert_sym || (sym == quote_sym && (!iscons(car_(e))))) {
else if (iscons(e) && (sym == inert_sym || (sym == quote_sym && (!iscons(car_(e)))))) {
ex = scm_to_julia_(fl_ctx, car_(e), mod);
temp = jl_new_struct(jl_quotenode_type, ex);
}
Expand Down
3 changes: 2 additions & 1 deletion src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,8 @@ static int check_ambiguous_visitor(jl_typemap_entry_t *oldentry, struct typemap_

// ok: record that this method definition is being partially replaced
// (either with a real definition, or an ambiguity error)
if (shadowed) {
// be careful not to try to scan something from the current dump-reload though
if (shadowed && oldentry->min_world != closure->newentry->min_world) {
if (closure->shadowed == NULL) {
closure->shadowed = (jl_value_t*)oldentry;
}
Expand Down
2 changes: 1 addition & 1 deletion src/jlfrontend.scm
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
(jl-expand-to-thunk
(let* ((name (caddr e))
(body (cadddr e))
(loc (cadr body))
(loc (if (null? (cdr body)) () (cadr body)))
(loc (if (and (pair? loc) (eq? (car loc) 'line))
(list loc)
'()))
Expand Down
2 changes: 2 additions & 0 deletions src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -3761,6 +3761,8 @@ JL_DLLEXPORT int jl_type_morespecific(jl_value_t *a, jl_value_t *b)
{
if (obviously_disjoint(a, b, 1))
return 0;
if (jl_has_free_typevars(a) || jl_has_free_typevars(b))
return 0;
if (jl_subtype(b, a))
return 0;
if (jl_subtype(a, b))
Expand Down
5 changes: 5 additions & 0 deletions src/toplevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ jl_value_t *jl_eval_module_expr(jl_module_t *parent_module, jl_expr_t *ex)
if (jl_array_len(ex->args) != 3 || !jl_is_expr(jl_exprarg(ex, 2))) {
jl_error("syntax: malformed module expression");
}

if (((jl_expr_t *)(jl_exprarg(ex, 2)))->head != jl_symbol("block")) {
jl_error("syntax: module expression third argument must be a block");
}

int std_imports = (jl_exprarg(ex, 0) == jl_true);
jl_sym_t *name = (jl_sym_t*)jl_exprarg(ex, 1);
if (!jl_is_symbol(name)) {
Expand Down
4 changes: 3 additions & 1 deletion stdlib/LinearAlgebra/src/triangular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2566,7 +2566,9 @@ function sqrt(A::UpperTriangular{T},::Val{realmatrix}) where {T,realmatrix}
@simd for k = i+1:j-1
r -= R[i,k]*R[k,j]
end
iszero(r) || (R[i,j] = sylvester(R[i,i],R[j,j],-r))
if !(iszero(r) || (iszero(R[i,i]) && iszero(R[j,j])))
R[i,j] = sylvester(R[i,i],R[j,j],-r)
end
end
end
return UpperTriangular(R)
Expand Down
6 changes: 6 additions & 0 deletions stdlib/LinearAlgebra/test/triangular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -611,4 +611,10 @@ end
end
end

# Issue 35058
let A = [0.9999999999999998 4.649058915617843e-16 -1.3149405273715513e-16 9.9959579317056e-17; -8.326672684688674e-16 1.0000000000000004 2.9280733590254494e-16 -2.9993900031619594e-16; 9.43689570931383e-16 -1.339206523454095e-15 1.0000000000000007 -8.550505126287743e-16; -6.245004513516506e-16 -2.0122792321330962e-16 1.183061278035052e-16 1.0000000000000002],
B = [0.09648289218436859 0.023497875751503007 0.0 0.0; 0.023497875751503007 0.045787575150300804 0.0 0.0; 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0]
@test sqrt(A*B*A')^2 A*B*A'
end

end # module TestTriangular
4 changes: 2 additions & 2 deletions stdlib/Pkg.version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PKG_BRANCH = master
PKG_SHA1 = 9419c70af69153cd5c4276bff90fbb135e0aa3f1
PKG_BRANCH = release-1.4
PKG_SHA1 = 38f72686c378a4c61d382fe3b081f3435942ac82
1 change: 1 addition & 0 deletions stdlib/Random/src/RNGs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ else # !windows
end

rand(rd::RandomDevice, sp::SamplerBoolBitInteger) = read(getfile(rd), sp[])
rand(rd::RandomDevice, ::SamplerType{Bool}) = read(getfile(rd), UInt8) % Bool

function getfile(rd::RandomDevice)
devrandom = rd.unlimited ? DEV_URANDOM : DEV_RANDOM
Expand Down
32 changes: 32 additions & 0 deletions stdlib/Random/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,38 @@ for rng in [MersenneTwister(), RandomDevice()],
end
end

@testset "rand(Bool) uniform distribution" begin
for n in [rand(1:8), rand(9:16), rand(17:64)]
a = zeros(Bool, n)
as = zeros(Int, n)
# we will test statistical properties for each position of a,
# but also for 3 linear combinations of positions (for the array version)
lcs = unique!.([rand(1:n, 2), rand(1:n, 3), rand(1:n, 5)])
aslcs = zeros(Int, 3)
for rng = (MersenneTwister(), RandomDevice())
for scalar = [false, true]
fill!(a, 0)
fill!(as, 0)
fill!(aslcs, 0)
for _ = 1:49
if scalar
for i in eachindex(as)
as[i] += rand(rng, Bool)
end
else
as .+= rand!(rng, a)
aslcs .+= [xor(getindex.(Ref(a), lcs[i])...) for i in 1:3]
end
end
@test all(x -> 7 <= x <= 42, as) # for each x, fails with proba ≈ 2/35_000_000
if !scalar
@test all(x -> 7 <= x <= 42, aslcs)
end
end
end
end
end

# test reproducility of methods
let mta = MersenneTwister(42), mtb = MersenneTwister(42)

Expand Down
12 changes: 12 additions & 0 deletions test/iobuffer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,18 @@ end
@test close(bstream) === nothing
@test eof(bstream)
@test bytesavailable(bstream) == 0
flag = Ref{Bool}(false)
event = Base.Event()
bstream = Base.BufferStream()
task = @async begin
notify(event)
read(bstream, 16)
flag[] = true
end
wait(event)
write(bstream, rand(UInt8, 16))
wait(task)
@test flag[] == true
end

@test flush(IOBuffer()) === nothing # should be a no-op
Expand Down
15 changes: 15 additions & 0 deletions test/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -596,3 +596,18 @@ end
seekstart(io)
@test_throws ErrorException read!(io, @view z[4:6])
end

# Bulk read from pipe
let p = Pipe()
data = rand(UInt8, Base.SZ_UNBUFFERED_IO + 100)
Base.link_pipe!(p, reader_supports_async=true, writer_supports_async=true)
t = @async write(p.in, data)
@test read(p.out, UInt8) == data[1]
data_read = Vector{UInt8}(undef, 10*Base.SZ_UNBUFFERED_IO)
nread = readbytes!(p.out, data_read, Base.SZ_UNBUFFERED_IO + 50)
@test nread == Base.SZ_UNBUFFERED_IO + 50
@test data_read[1:nread] == data[2:nread+1]
@test read(p.out, 49) == data[end-48:end]
wait(t)
close(p)
end
3 changes: 3 additions & 0 deletions test/regex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,7 @@
# Test that PCRE throws the correct kind of error
# TODO: Uncomment this once the corresponding change has propagated to CI
#@test_throws ErrorException Base.PCRE.info(C_NULL, Base.PCRE.INFO_NAMECOUNT, UInt32)

# test that we can get the error message of negative error codes
@test Base.PCRE.err_message(Base.PCRE.ERROR_NOMEMORY) isa String
end
Loading

0 comments on commit 58353fd

Please sign in to comment.