summaryrefslogtreecommitdiff
path: root/numpy/core/src/scalarmathmodule.c.src
diff options
context:
space:
mode:
authorArink Verma <arinkverma@gmail.com>2013-08-30 02:04:52 +0530
committerArink Verma <arinkverma@gmail.com>2013-08-30 02:14:29 +0530
commitd334dbd400964515bb392f3f9d7978d0ddb2a9a6 (patch)
tree614bb8891f253142b26f3f16e30c2571667eac56 /numpy/core/src/scalarmathmodule.c.src
parent7b415b26f4a1d58164a69ef44fb501fbd93e666f (diff)
downloadnumpy-d334dbd400964515bb392f3f9d7978d0ddb2a9a6.tar.gz
Replaced PyInt_As_Long with PyInt_AsLong and errorchecking
Diffstat (limited to 'numpy/core/src/scalarmathmodule.c.src')
-rw-r--r--numpy/core/src/scalarmathmodule.c.src37
1 files changed, 27 insertions, 10 deletions
diff --git a/numpy/core/src/scalarmathmodule.c.src b/numpy/core/src/scalarmathmodule.c.src
index 3fa1deb35..c4bb082dc 100644
--- a/numpy/core/src/scalarmathmodule.c.src
+++ b/numpy/core/src/scalarmathmodule.c.src
@@ -783,13 +783,19 @@ _@name@_convert_to_ctype(PyObject *a, @type@ *arg1)
#if PY_VERSION_HEX < 0x03000000
if (PyInt_CheckExact(a)) {
- *arg1 = PyInt_AS_LONG(a);
- return 0;
+ *arg1 = PyInt_AsLong(a);
+ if (*arg1 == -1 && PyErr_Occurred()) {
+ return -1;
+ }
+ else {
+ return 0;
+ }
}
#endif
if(PyLong_CheckExact(a)) {
- if ((*arg1 = PyLong_AsUnsignedLong(a)) == -1 && PyErr_Occurred()) {
+ *arg1 = PyLong_AsUnsignedLong(a);
+ if (*arg1 == -1 && PyErr_Occurred()) {
return -1;
}
else {
@@ -847,13 +853,19 @@ _@name@_convert_to_ctype(PyObject *a, @type@ *arg1)
#if PY_VERSION_HEX < 0x03000000
if (PyInt_CheckExact(a)) {
- *arg1 = PyInt_AS_LONG(a);
- return 0;
+ *arg1 = PyInt_AsLong(a);
+ if (*arg1 == -1 && PyErr_Occurred()) {
+ return -1;
+ }
+ else {
+ return 0;
+ }
}
#endif
if(PyLong_CheckExact(a)) {
- if ((*arg1 = PyLong_AsLong(a)) == -1 && PyErr_Occurred()) {
+ *arg1 = PyLong_AsLong(a);
+ if (*arg1 == -1 && PyErr_Occurred()) {
return -1;
}
else {
@@ -909,16 +921,21 @@ _@name@_convert_to_ctype(PyObject *a, @type@ *arg1)
{
PyObject *temp;
-
#if PY_VERSION_HEX < 0x03000000
if (PyInt_CheckExact(a)) {
- *arg1 = PyInt_AS_LONG(a);
- return 0;
+ *arg1 = PyInt_AsLong(a);
+ if (*arg1 == -1 && PyErr_Occurred()) {
+ return -1;
+ }
+ else {
+ return 0;
+ }
}
#endif
if (PyLong_CheckExact(a)) {
- if ((*arg1 = @PYEXTRACTCTYPE@(a)) == -1 && PyErr_Occurred()) {
+ *arg1 = @PYEXTRACTCTYPE@(a);
+ if (*arg1 == (@type@)-1 && PyErr_Occurred()) {
return -1;
}
else {