Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修正只有kwargs没有args时报错 #28

Merged
merged 5 commits into from
Dec 26, 2023
Merged

Conversation

he426100
Copy link
Contributor

@he426100 he426100 commented Dec 25, 2023

复现代码

$namedtuple = PyCore::import('collections')->namedtuple;

$Person = $namedtuple('Person', ["name", "age", "gender"]);
$p1 = $Person(name: "阮奇桢", age: 40, gender: "男");
PyCore::print($p1->name);

运行会 [1] 11886 segmentation fault php test.php
gdb调试发现在 value = PyObject_Call(fn, args, kwargs);处 出错,根据文档 调用对象的 API PyObject_Call的第二个参数 args 是可以为空的,此时应该传 空元组。

如果不改 bride/core.cc的话 第一个参数必须是 args,所以php中要改成 $p1 = $Person("阮奇桢", age: 40, gender: "男");,但这样显得很奇怪,与python不一致了

@matyhtf matyhtf merged commit 23d143f into swoole:main Dec 26, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants