This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author kumma
Recipients brian.curtin, eric.araujo, kumma, theller
Date 2010-06-22.07:43:56
SpamBayes Score 0.000411069
Marked as misclassified No
Message-id <AANLkTikNkj58_DL4tmDItpUrmScm_dtl-pX6LI1QgRLT@mail.gmail.com>
In-reply-to <1277140034.13.0.259802323608.issue9041@psf.upfronthosting.co.za>
Content
I'm a newbie what it comes to Python's C-sources, so please do not
take me too seriously.
I fetched the sources 'svn checkout
http://svn.python.org/projects/python/branches/release26-maint '
studied the issue, and my best guess is that
Modules/_ctypes/cfield.c 's funktion d_set is called, when converting
something to ctypes.c_double

Please check, that this is what happens :)

If so, Objects/longobject.c's function double PyLong_AsDouble(PyObject
*vv) sets the overflow exception, but d_set overwrites it, like you
can see:

static PyObject *
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);
        return NULL;
    }
    memcpy(ptr, &x, sizeof(double));
    _RET(value);
}

Perhaps something like:
if (PyErr_ExceptionMatches(PyExc_OverflowError)){
	return NULL;
}

just after the line:
'f (x == -1 && PyErr_Occurred()) {'
could fix this?

 But like I said, I'm an newbie, this was actually my first  look into
Python/C API  and I have not tested this fix in any way whatsoever
History
Date User Action Args
2010-06-22 07:43:59kummasetrecipients: + kumma, theller, eric.araujo, brian.curtin
2010-06-22 07:43:57kummalinkissue9041 messages
2010-06-22 07:43:56kummacreate