If the value of *obj* is out of range for an :c:type:`unsigned long`,
return the reduction of that value modulo ``ULONG_MAX + 1``.
- Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
+ Returns ``(unsigned long)-1`` on error. Use :c:func:`PyErr_Occurred` to
+ disambiguate.
.. c:function:: unsigned long long PyLong_AsUnsignedLongLongMask(PyObject *obj)
If the value of *obj* is out of range for an :c:type:`unsigned long long`,
return the reduction of that value modulo ``PY_ULLONG_MAX + 1``.
- Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
+ Returns ``(unsigned long long)-1`` on error. Use :c:func:`PyErr_Occurred`
+ to disambiguate.
.. c:function:: double PyLong_AsDouble(PyObject *pylong)
return Py_None;
}
+static PyObject *
+test_long_as_unsigned_long_long_mask(PyObject *self,
+ PyObject *Py_UNUSED(ignored))
+{
+ unsigned long long res = PyLong_AsUnsignedLongLongMask(NULL);
+
+ if (res != (unsigned long long)-1 || !PyErr_Occurred()) {
+ return raiseTestError("test_long_as_unsigned_long_long_mask",
+ "PyLong_AsUnsignedLongLongMask(NULL) didn't "
+ "complain");
+ }
+ if (!PyErr_ExceptionMatches(PyExc_SystemError)) {
+ return raiseTestError("test_long_as_unsigned_long_long_mask",
+ "PyLong_AsUnsignedLongLongMask(NULL) raised "
+ "something other than SystemError");
+ }
+ PyErr_Clear();
+ Py_RETURN_NONE;
+}
+
/* Test the PyLong_AsDouble API. At present this just tests that
non-integer arguments are handled correctly.
*/
METH_NOARGS},
{"test_long_as_double", (PyCFunction)test_long_as_double,METH_NOARGS},
{"test_long_as_size_t", (PyCFunction)test_long_as_size_t,METH_NOARGS},
+ {"test_long_as_unsigned_long_long_mask",
+ (PyCFunction)test_long_as_unsigned_long_long_mask, METH_NOARGS},
{"test_long_numbits", (PyCFunction)test_long_numbits, METH_NOARGS},
{"test_k_code", (PyCFunction)test_k_code, METH_NOARGS},
{"test_empty_argparse", (PyCFunction)test_empty_argparse,METH_NOARGS},
if (vv == NULL || !PyLong_Check(vv)) {
PyErr_BadInternalCall();
- return (unsigned long) -1;
+ return (unsigned long long) -1;
}
v = (PyLongObject *)vv;
switch(Py_SIZE(v)) {
if (op == NULL) {
PyErr_BadInternalCall();
- return (unsigned long)-1;
+ return (unsigned long long)-1;
}
if (PyLong_Check(op)) {