| 1709 | } |
| 1710 | |
| 1711 | static inline int PyLong_AsUInt32(PyObject *obj, uint32_t *pvalue) |
| 1712 | { |
| 1713 | Py_BUILD_ASSERT(sizeof(long) >= 4); |
| 1714 | unsigned long value = PyLong_AsUnsignedLong(obj); |
| 1715 | if (value == (unsigned long)-1 && PyErr_Occurred()) { |
| 1716 | return -1; |
| 1717 | } |
| 1718 | #if SIZEOF_LONG > 4 |
| 1719 | if ((unsigned long)UINT32_MAX < value) { |
| 1720 | PyErr_SetString(PyExc_OverflowError, |
| 1721 | "Python int too large to convert to C uint32_t"); |
| 1722 | return -1; |
| 1723 | } |
| 1724 | #endif |
| 1725 | *pvalue = (uint32_t)value; |
| 1726 | return 0; |
| 1727 | } |
| 1728 | |
| 1729 | static inline int PyLong_AsUInt64(PyObject *obj, uint64_t *pvalue) |
| 1730 | { |
nothing calls this directly
no outgoing calls
no test coverage detected