Skip to content

Commit

Permalink
Backports release 1.11 (#55855)
Browse files Browse the repository at this point in the history
Backported PRs:
- [x] #55773 <!-- Add compat entry for `Base.donotdelete` -->
- [x] #41244 <!-- Fix shell `cd` error when working dir has been deleted
-->
- [x] #55795 <!-- fix #52986, regression in `@doc` of macro without REPL
loaded -->
- [x] #55829 <!-- [Dates] Make test more robust against non-UTC
timezones -->
- [x] #55641 <!-- fall back to slower stat filesize if optimized
filesize fails -->
- [x] #55744 <!-- fix #45494, error in ssa conversion with complex type
decl -->
- [x] #55783 <!-- use `inferencebarrier` instead of `invokelatest` for
1-arg `@assert` -->
- [x] #55739 <!-- Add `invokelatest` barrier to `string(...)` in
`@assert` -->

Need manual backport:
- [ ] #55798 <!-- Broadcast binary ops involving strided triangular -->

Contains multiple commits, manual intervention needed:
- [ ] #55509 <!-- Fix cong implementation to be properly random and not
just cycling. -->
- [ ] #55569 <!-- Add a docs section about loading/precomp/ttfx time
tuning -->
- [ ] #55824 <!-- Replace regex package module checks with actual code
checks -->

Non-merged PRs with backport label:
- [ ] #55845 <!-- privatize annotated string API, take two -->
- [ ] #55828 <!-- Fix some corner cases of `isapprox` with unsigned
integers -->
- [ ] #55813 <!-- Check for conflicting `@ccallable` name before JIT
registration -->
- [ ] #55743 <!-- doc: heap snapshot viewing -->
- [ ] #55741 <!-- Change annotations to use a NamedTuple -->
- [ ] #55534 <!-- Set stdlib sources as read-only during installation
-->
- [ ] #55499 <!-- propagate the terminal's `displaysize` to the
`IOContext` used by the REPL -->
- [ ] #55458 <!-- Allow for generically extracting unannotated string
-->
- [ ] #55457 <!-- Make AnnotateChar equality consider annotations -->
- [ ] #55453 <!-- Privatise the annotations API, for StyledStrings -->
- [ ] #55355 <!-- relocation: account for trailing path separator in
depot paths -->
- [ ] #55220 <!-- `isfile_casesensitive` fixes on Windows -->
- [ ] #55169 <!-- `propertynames` for SVD respects private argument -->
- [ ] #54457 <!-- Make `String(::Memory)` copy -->
- [ ] #53957 <!-- tweak how filtering is done for what packages should
be precompiled -->
- [ ] #51479 <!-- prevent code loading from lookin in the versioned
environment when building Julia -->
- [ ] #50813 <!-- More doctests for Sockets and capitalization fix -->
- [ ] #50157 <!-- improve docs for `@inbounds` and
`Base.@propagate_inbounds` -->
  • Loading branch information
KristofferC authored Sep 25, 2024
2 parents 6cb5b1f + 704fdc6 commit a28592d
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 38 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ Standard library changes
writes 4 bytes for each character, instead of writing the UTF-8 representation of each character.
The new format is compatible with that used by `Array`, making it possible to use `read!` to get
the data back ([#42593]).
* It's not possible to define `length` for stateful iterators in a generally consistent manner. The
potential for silently incorrect results for `Stateful` iterators is addressed by deleting the
`length(::Stateful)` method. The last type parameter of `Stateful` is gone, too. Issue: ([#47790]),
PR: ([#51747]).

#### StyledStrings

Expand Down
13 changes: 9 additions & 4 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ function repl_cmd(cmd, out)
if isempty(cmd.exec)
throw(ArgumentError("no cmd to execute"))
elseif cmd.exec[1] == "cd"
new_oldpwd = pwd()
if length(cmd.exec) > 2
throw(ArgumentError("cd method only takes one argument"))
elseif length(cmd.exec) == 2
Expand All @@ -52,11 +51,17 @@ function repl_cmd(cmd, out)
end
dir = ENV["OLDPWD"]
end
cd(dir)
else
cd()
dir = homedir()
end
ENV["OLDPWD"] = new_oldpwd
try
ENV["OLDPWD"] = pwd()
catch ex
ex isa IOError || rethrow()
# if current dir has been deleted, then pwd() will throw an IOError: pwd(): no such file or directory (ENOENT)
delete!(ENV, "OLDPWD")
end
cd(dir)
println(out, pwd())
else
@static if !Sys.iswindows()
Expand Down
4 changes: 4 additions & 0 deletions base/docs/Docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,10 @@ function _doc(binding::Binding, sig::Type = Union{})
for msig in multidoc.order
sig <: msig && return multidoc.docs[msig]
end
# if no matching signatures, return first
if !isempty(multidoc.docs)
return first(values(multidoc.docs))
end
end
end
return nothing
Expand Down
3 changes: 3 additions & 0 deletions base/docs/basedocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3643,6 +3643,9 @@ unused and delete the entire benchmark code).
which the value of the arguments of this intrinsic were available (in a register,
in memory, etc.).
!!! compat "Julia 1.8"
This method was added in Julia 1.8.
# Examples
```julia
Expand Down
6 changes: 4 additions & 2 deletions base/error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,16 @@ macro assert(ex, msgs...)
msg = msg # pass-through
elseif !isempty(msgs) && (isa(msg, Expr) || isa(msg, Symbol))
# message is an expression needing evaluating
msg = :(Main.Base.string($(esc(msg))))
# N.B. To reduce the risk of invalidation caused by the complex callstack involved
# with `string`, use `inferencebarrier` here to hide this `string` from the compiler.
msg = :(Main.Base.inferencebarrier(Main.Base.string)($(esc(msg))))
elseif isdefined(Main, :Base) && isdefined(Main.Base, :string) && applicable(Main.Base.string, msg)
msg = Main.Base.string(msg)
else
# string() might not be defined during bootstrap
msg = quote
msg = $(Expr(:quote,msg))
isdefined(Main, :Base) ? Main.Base.string(msg) :
isdefined(Main, :Base) ? Main.Base.inferencebarrier(Main.Base.string)(msg) :
(Core.println(msg); "Error during bootstrap. See stdout.")
end
end
Expand Down
7 changes: 0 additions & 7 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1096,15 +1096,8 @@ public
Lockable,
OneTo,
LogRange,
AnnotatedString,
AnnotatedChar,
UUID,

# Annotated strings
annotatedstring,
annotate!,
annotations,

# Semaphores
Semaphore,
acquire,
Expand Down
4 changes: 2 additions & 2 deletions base/iostream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ end
function filesize(s::IOStream)
sz = @_lock_ios s ccall(:ios_filesize, Int64, (Ptr{Cvoid},), s.ios)
if sz == -1
err = Libc.errno()
throw(IOError(string("filesize: ", Libc.strerror(err), " for ", s.name), err))
# if `s` is not seekable `ios_filesize` can fail, so fall back to slower stat method
sz = filesize(stat(s))
end
return sz
end
Expand Down
14 changes: 0 additions & 14 deletions base/strings/annotated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ the combined range.
See also [`AnnotatedChar`](@ref), [`annotatedstring`](@ref),
[`annotations`](@ref), and [`annotate!`](@ref).
!!! warning
While the constructors are part of the Base public API, the fields
of `AnnotatedString` are not. This is to allow for potential future
changes in the implementation of this type. Instead use the
[`annotations`](@ref), and [`annotate!`](@ref) getter/setter
functions.
# Constructors
```julia
Expand Down Expand Up @@ -81,13 +74,6 @@ More specifically, this is a simple wrapper around any other
See also: [`AnnotatedString`](@ref), [`annotatedstring`](@ref), `annotations`,
and `annotate!`.
!!! warning
While the constructors are part of the Base public API, the fields
of `AnnotatedChar` are not. This it to allow for potential future
changes in the implementation of this type. Instead use the
[`annotations`](@ref), and [`annotate!`](@ref) getter/setter
functions.
# Constructors
```julia
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2472bd6434d21c4b3e3199437e6fdcf7
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0a3fa9a09de81aa9676dbc7448408c7503f45e42519a2667540ad890316c7da089c95de5464a2032171f963c6f3cba73d6b3c246f1c7ac6ede283fc8132d5209
19 changes: 14 additions & 5 deletions doc/src/base/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ Core.String(::AbstractString)
Base.SubString
Base.LazyString
Base.@lazy_str
Base.AnnotatedString
Base.AnnotatedChar
Base.annotatedstring
Base.annotations
Base.annotate!
Base.transcode
Base.unsafe_string
Base.ncodeunits(::AbstractString)
Expand Down Expand Up @@ -98,3 +93,17 @@ Base.escape_string
Base.escape_raw_string
Base.unescape_string
```

## `AnnotatedString`s

!!! note
The API for AnnotatedStrings is considered experimental and is subject to change between
Julia versions.

```@docs
Base.AnnotatedString
Base.AnnotatedChar
Base.annotatedstring
Base.annotations
Base.annotate!
```
4 changes: 4 additions & 0 deletions doc/src/manual/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,10 @@ last backslash escapes a quote, since these backslashes appear before a quote.

## [Annotated Strings](@id man-annotated-strings)

!!! note
The API for AnnotatedStrings is considered experimental and is subject to change between
Julia versions.

It is sometimes useful to be able to hold metadata relating to regions of a
string. A [`AnnotatedString`](@ref Base.AnnotatedString) wraps another string and
allows for regions of it to be annotated with labelled values (`:label => value`).
Expand Down
6 changes: 5 additions & 1 deletion stdlib/Dates/test/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,11 @@ end
end

@testset "issue #31524" begin
dt1 = Libc.strptime("%Y-%M-%dT%H:%M:%SZ", "2018-11-16T10:26:14Z")
# Ensure the result doesn't depend on local timezone, especially on macOS
# where an extra internal call to `mktime` is affected by timezone settings.
dt1 = withenv("TZ" => "UTC") do
Libc.strptime("%Y-%m-%dT%H:%M:%SZ", "2018-11-16T10:26:14Z")
end
dt2 = Libc.TmStruct(14, 30, 5, 10, 1, 99, 3, 40, 0)

time = Time(dt1)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Downloads.version
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DOWNLOADS_BRANCH = master
DOWNLOADS_SHA1 = 1061ecc377a053fce0df94e1a19e5260f7c030f5
DOWNLOADS_SHA1 = 89d3c7dded535a77551e763a437a6d31e4d9bf84
DOWNLOADS_GIT_URL := https://github.com/JuliaLang/Downloads.jl.git
DOWNLOADS_TAR_URL = https://api.github.com/repos/JuliaLang/Downloads.jl/tarball/$1
1 change: 1 addition & 0 deletions test/docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Base.Docs: meta, @var, DocStr, parsedoc

# check that @doc can work before REPL is loaded
@test !startswith(read(`$(Base.julia_cmd()) -E '@doc sin'`, String), "nothing")
@test !startswith(read(`$(Base.julia_cmd()) -E '@doc @time'`, String), "nothing")

using Markdown
using REPL
Expand Down
20 changes: 20 additions & 0 deletions test/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,26 @@ end
end
end

@testset "pwd tests" begin
mktempdir() do dir
cd(dir) do
withenv("OLDPWD" => nothing) do
io = IOBuffer()
Base.repl_cmd(@cmd("cd"), io)
Base.repl_cmd(@cmd("cd -"), io)
@test realpath(pwd()) == realpath(dir)
if !Sys.iswindows()
# Delete the working directory and check we can cd out of it
# Cannot delete the working directory on Windows
rm(dir)
@test_throws Base._UVError("pwd()", Base.UV_ENOENT) pwd()
Base.repl_cmd(@cmd("cd \\~"), io)
end
end
end
end
end

@testset "readdir tests" begin
(a, b) = sort(a) == sort(b)
mktempdir() do dir
Expand Down

0 comments on commit a28592d

Please sign in to comment.