{
long long_val;
+ if (!obj) {
+ PyErr_SetString(PyExc_TypeError, "unexpected type");
+ return -1;
+ }
+
/* If obj is type of PyInt_Type, PyInt_AsLong converts it
* to C long type directly. If it is of PyLong_Type, PyInt_AsLong
* will call PyLong_AsLong() to deal with it automatically.
{
long long_val;
+ if (!obj) {
+ PyErr_SetString(PyExc_TypeError, "unexpected type");
+ return -1;
+ }
+
long_val = PyInt_AsLong(obj);
if ((long_val == -1) && PyErr_Occurred())
return -1;
{
long long_val;
+ if (!obj) {
+ PyErr_SetString(PyExc_TypeError, "unexpected type");
+ return -1;
+ }
+
long_val = PyInt_AsLong(obj);
if ((long_val == -1) && PyErr_Occurred())
return -1;
{
long long_val;
+ if (!obj) {
+ PyErr_SetString(PyExc_TypeError, "unexpected type");
+ return -1;
+ }
+
long_val = PyInt_AsLong(obj);
if ((long_val == -1) && PyErr_Occurred())
return -1;
{
long long llong_val;
+ if (!obj) {
+ PyErr_SetString(PyExc_TypeError, "unexpected type");
+ return -1;
+ }
+
/* If obj is of PyInt_Type, PyLong_AsLongLong
* will call PyInt_AsLong() to handle it automatically.
*/
unsigned long long ullong_val = -1;
long long llong_val;
+ if (!obj) {
+ PyErr_SetString(PyExc_TypeError, "unexpected type");
+ return -1;
+ }
+
/* The PyLong_AsUnsignedLongLong doesn't check the type of
* obj, only accept argument of PyLong_Type, so we check it instead.
*/
{
double double_val;
+ if (!obj) {
+ PyErr_SetString(PyExc_TypeError, "unexpected type");
+ return -1;
+ }
+
double_val = PyFloat_AsDouble(obj);
if ((double_val == -1) && PyErr_Occurred())
return -1;
{
int ret;
- ret = PyObject_IsTrue(obj);
- if (ret < 0)
+ if (!obj) {
+ PyErr_SetString(PyExc_TypeError, "unexpected type");
+ return -1;
+ }
+
+ if ((ret = PyObject_IsTrue(obj)) < 0)
return ret;
*val = ret > 0;