diff --git a/src/Core/builtins.jl b/src/Core/builtins.jl index 6a501526..eb4dd670 100644 --- a/src/Core/builtins.jl +++ b/src/Core/builtins.jl @@ -1098,6 +1098,7 @@ pydict(; kwargs...) = isempty(kwargs) ? pynew(errcheck(C.PyDict_New())) : pystrdict_fromiter(kwargs) pydict(x) = ispy(x) ? pybuiltins.dict(x) : pydict_fromiter(x) pydict(x::NamedTuple) = pydict(; x...) +pydict(pairs::Pair...) = pydict(pairs) export pydict ### datetime diff --git a/test/Core.jl b/test/Core.jl index c5a9b48e..4f50a1fe 100644 --- a/test/Core.jl +++ b/test/Core.jl @@ -508,6 +508,10 @@ end @test pyeq(Bool, pydict(Dict("foo" => 1, "bar" => 2)), x) @test pyeq(Bool, pydict((foo = 1, bar = 2)), x) @test pyeq(Bool, pydict(x), x) + y = pydict("foo" => 1, "bar" => 2) + @test pyeq(Bool, pygetitem(y, "foo"), 1) + @test pyeq(Bool, pygetitem(y, "bar"), 2) + @test pyeq(Bool, x, y) end @testitem "bool" begin