mirror of
https://github.com/pybind/pybind11.git
synced 2025-01-31 23:30:30 +00:00
unpacking_collector: allow nullptr-valued kwargs argument
This fixes an issue that can arise when forwarding (*args, **kwargs) captured from a pybind11-bound function call to another Python function. When the initial function call includes no keyword arguments, the py::kwargs field is set to nullptr and causes a crash later on.
This commit is contained in:
parent
ba7678016c
commit
e71ab8f455
@ -1218,10 +1218,9 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void process(list &args_list, detail::args_proxy ap) {
|
void process(list &args_list, detail::args_proxy ap) {
|
||||||
for (const auto &a : ap) {
|
for (const auto &a : ap)
|
||||||
args_list.append(a);
|
args_list.append(a);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void process(list &/*args_list*/, arg_v a) {
|
void process(list &/*args_list*/, arg_v a) {
|
||||||
if (m_kwargs.contains(a.name)) {
|
if (m_kwargs.contains(a.name)) {
|
||||||
@ -1242,6 +1241,8 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void process(list &/*args_list*/, detail::kwargs_proxy kp) {
|
void process(list &/*args_list*/, detail::kwargs_proxy kp) {
|
||||||
|
if (!kp)
|
||||||
|
return;
|
||||||
for (const auto &k : dict(kp, true)) {
|
for (const auto &k : dict(kp, true)) {
|
||||||
if (m_kwargs.contains(k.first)) {
|
if (m_kwargs.contains(k.first)) {
|
||||||
#if defined(NDEBUG)
|
#if defined(NDEBUG)
|
||||||
|
Loading…
Reference in New Issue
Block a user