------------------------------------------------------------------------------ Raise a type error for a sequence arg of wrong type or size.
| 1565 | //------------------------------------------------------------------------------ |
| 1566 | // Raise a type error for a sequence arg of wrong type or size. |
| 1567 | bool vtkPythonSequenceError(PyObject* o, size_t n, size_t m) |
| 1568 | { |
| 1569 | char text[80]; |
| 1570 | if (m == n) |
| 1571 | { |
| 1572 | |
| 1573 | auto result = |
| 1574 | vtk::format_to_n(text, sizeof(text), "expected a sequence of {:d} value{:s}, got {:s}", |
| 1575 | static_cast<long long>(n), ((n == 1) ? "" : "s"), vtkPythonUtil::GetTypeNameForObject(o)); |
| 1576 | *result.out = '\0'; |
| 1577 | } |
| 1578 | else |
| 1579 | { |
| 1580 | auto result = |
| 1581 | vtk::format_to_n(text, sizeof(text), "expected a sequence of {:d} value{:s}, got {:d} values", |
| 1582 | static_cast<long long>(n), ((n == 1) ? "" : "s"), static_cast<long long>(m)); |
| 1583 | *result.out = '\0'; |
| 1584 | } |
| 1585 | PyErr_SetString(PyExc_TypeError, text); |
| 1586 | return false; |
| 1587 | } |
| 1588 | |
| 1589 | //------------------------------------------------------------------------------ |
| 1590 | // Checking size of array arg. |
no test coverage detected