Skip to content

Commit 28ba994

Browse files
committed
Allow pydict accept Pair args
1 parent 0a7d49f commit 28ba994

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/Core/builtins.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,7 @@ pydict(; kwargs...) =
10981098
isempty(kwargs) ? pynew(errcheck(C.PyDict_New())) : pystrdict_fromiter(kwargs)
10991099
pydict(x) = ispy(x) ? pybuiltins.dict(x) : pydict_fromiter(x)
11001100
pydict(x::NamedTuple) = pydict(; x...)
1101+
pydict(pairs::Pair...) = pydict(pairs)
11011102
export pydict
11021103

11031104
### datetime

test/Core.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,10 @@ end
508508
@test pyeq(Bool, pydict(Dict("foo" => 1, "bar" => 2)), x)
509509
@test pyeq(Bool, pydict((foo = 1, bar = 2)), x)
510510
@test pyeq(Bool, pydict(x), x)
511+
y = pydict("foo" => 1, "bar" => 2)
512+
@test pyeq(Bool, pygetitem(y, "foo"), 1)
513+
@test pyeq(Bool, pygetitem(y, "bar"), 2)
514+
@test pyeq(Bool, x, y)
511515
end
512516

513517
@testitem "bool" begin

0 commit comments

Comments
 (0)