| 629 | |
| 630 | template <typename T> |
| 631 | static bool py_long_to_integral_range(PyObject *value, const char *type_name, |
| 632 | T *out) { |
| 633 | int64_t converted = 0; |
| 634 | if (!py_long_to_int64(value, &converted)) { |
| 635 | return false; |
| 636 | } |
| 637 | constexpr int64_t k_min = static_cast<int64_t>(std::numeric_limits<T>::min()); |
| 638 | constexpr int64_t k_max = static_cast<int64_t>(std::numeric_limits<T>::max()); |
| 639 | if (converted < k_min || converted > k_max) { |
| 640 | PyErr_Format(PyExc_OverflowError, "integer out of range for %s", type_name); |
| 641 | return false; |
| 642 | } |
| 643 | *out = static_cast<T>(converted); |
| 644 | return true; |
| 645 | } |
| 646 | |
| 647 | template <typename T> |
| 648 | static bool py_long_to_unsigned_range(PyObject *value, const char *type_name, |
nothing calls this directly
no test coverage detected