MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / PyLong_AsUInt32

Function PyLong_AsUInt32

asyncpg/protocol/record/pythoncapi_compat.h:1711–1727  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1709}
1710
1711static 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
1729static inline int PyLong_AsUInt64(PyObject *obj, uint64_t *pvalue)
1730{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected