summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMeador Inge <meadori@gmail.com>2012-05-28 19:47:53 (GMT)
committerMeador Inge <meadori@gmail.com>2012-05-28 19:47:53 (GMT)
commitd102e04e4a9f84f632c5dfff5e7d3aae7022b33e (patch)
treebfd2462871d5775da6279b8f7aa8e8444f989ce9 /Modules
parentef4c5010e45924c4c21441e372e83463e66515d5 (diff)
parent031e25b0f74ae2c7c82a6d2a3c227e74278b22d9 (diff)
downloadcpython-d102e04e4a9f84f632c5dfff5e7d3aae7022b33e.zip
cpython-d102e04e4a9f84f632c5dfff5e7d3aae7022b33e.tar.gz
cpython-d102e04e4a9f84f632c5dfff5e7d3aae7022b33e.tar.bz2
Issue #9041: raised exception is misleading
An issue in ctypes.c_longdouble, ctypes.c_double, and ctypes.c_float that caused an incorrect exception to be returned in the case of overflow has been fixed.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/cfield.c30
1 files changed, 5 insertions, 25 deletions
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c
index 1c4eba9..14bc981 100644
--- a/Modules/_ctypes/cfield.c
+++ b/Modules/_ctypes/cfield.c
@@ -999,12 +999,8 @@ g_set(void *ptr, PyObject *value, Py_ssize_t size)
long double x;
x = PyFloat_AsDouble(value);
- if (x == -1 && PyErr_Occurred()) {
- PyErr_Format(PyExc_TypeError,
- " float expected instead of %s instance",
- value->ob_type->tp_name);
+ if (x == -1 && PyErr_Occurred())
return NULL;
- }
memcpy(ptr, &x, sizeof(long double));
_RET(value);
}
@@ -1023,12 +1019,8 @@ d_set(void *ptr, PyObject *value, Py_ssize_t size)
double x;
x = PyFloat_AsDouble(value);
- if (x == -1 && PyErr_Occurred()) {
- PyErr_Format(PyExc_TypeError,
- " float expected instead of %s instance",
- value->ob_type->tp_name);
+ if (x == -1 && PyErr_Occurred())
return NULL;
- }
memcpy(ptr, &x, sizeof(double));
_RET(value);
}
@@ -1047,12 +1039,8 @@ d_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
double x;
x = PyFloat_AsDouble(value);
- if (x == -1 && PyErr_Occurred()) {
- PyErr_Format(PyExc_TypeError,
- " float expected instead of %s instance",
- value->ob_type->tp_name);
+ if (x == -1 && PyErr_Occurred())
return NULL;
- }
#ifdef WORDS_BIGENDIAN
if (_PyFloat_Pack8(x, (unsigned char *)ptr, 1))
return NULL;
@@ -1079,12 +1067,8 @@ f_set(void *ptr, PyObject *value, Py_ssize_t size)
float x;
x = (float)PyFloat_AsDouble(value);
- if (x == -1 && PyErr_Occurred()) {
- PyErr_Format(PyExc_TypeError,
- " float expected instead of %s instance",
- value->ob_type->tp_name);
+ if (x == -1 && PyErr_Occurred())
return NULL;
- }
memcpy(ptr, &x, sizeof(x));
_RET(value);
}
@@ -1103,12 +1087,8 @@ f_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
float x;
x = (float)PyFloat_AsDouble(value);
- if (x == -1 && PyErr_Occurred()) {
- PyErr_Format(PyExc_TypeError,
- " float expected instead of %s instance",
- value->ob_type->tp_name);
+ if (x == -1 && PyErr_Occurred())
return NULL;
- }
#ifdef WORDS_BIGENDIAN
if (_PyFloat_Pack4(x, (unsigned char *)ptr, 1))
return NULL;