Skip to content

Commit

Permalink
Protect handle_message from Integer subtype invalidation (#39689)
Browse files Browse the repository at this point in the history
Resolves JuliaArrays/ArrayInterface.jl#121.
There is a cost, but hopefully there's no strong need to supply
`maxlog` using whacky subtypes of Integer.

(cherry picked from commit 67b9d4d)
  • Loading branch information
timholy authored and staticfloat committed Dec 22, 2022
1 parent 176a317 commit 8071f26
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/logging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ function handle_message(logger::SimpleLogger, level::LogLevel, message, _module,
filepath, line; kwargs...)
@nospecialize
maxlog = get(kwargs, :maxlog, nothing)
if maxlog isa Integer
if maxlog isa Core.BuiltinInts
remaining = get!(logger.message_limits, id, Int(maxlog)::Int)
logger.message_limits[id] = remaining - 1
remaining > 0 || return
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Logging/src/ConsoleLogger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function handle_message(logger::ConsoleLogger, level::LogLevel, message, _module
@nospecialize
hasmaxlog = haskey(kwargs, :maxlog) ? 1 : 0
maxlog = get(kwargs, :maxlog, nothing)
if maxlog isa Integer
if maxlog isa Core.BuiltinInts
remaining = get!(logger.message_limits, id, Int(maxlog)::Int)
logger.message_limits[id] = remaining - 1
remaining > 0 || return
Expand Down

0 comments on commit 8071f26

Please sign in to comment.