mirror of
https://github.com/RYDE-WORK/pybind11.git
synced 2026-02-02 21:45:53 +08:00
Fixed py:array constructor from failing for complex types
The array(const buffer_info &info) constructor fails when given
complex types since their format string is 'Zd' or 'Zf' which has
a length of two and causes an error here:
if (info.format.size() != 1)
throw std::runtime_error("Unsupported buffer format!");
Fixed by allowing format sizes of one and two.
This commit is contained in:
parent
61d67f0462
commit
ab92eb3765
@ -96,7 +96,7 @@ public:
|
|||||||
|
|
||||||
array(const buffer_info &info) {
|
array(const buffer_info &info) {
|
||||||
API& api = lookup_api();
|
API& api = lookup_api();
|
||||||
if (info.format.size() != 1)
|
if ((info.format.size() < 1) || (info.format.size() > 2))
|
||||||
throw std::runtime_error("Unsupported buffer format!");
|
throw std::runtime_error("Unsupported buffer format!");
|
||||||
int fmt = (int) info.format[0];
|
int fmt = (int) info.format[0];
|
||||||
if (info.format == "Zd")
|
if (info.format == "Zd")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user