[C++-sig] Re: numarray 1.0 and BPL - oops

David Abrahams dave at boost-consulting.com
Wed Sep 1 22:25:12 CEST 2004


Francois Ostiguy <ostiguy at fnal.gov> writes:

> the code that works for me is exactly as follows:
>
>
> long array_base::nelements() const
>   {
>     return extract<long>( attr("nelements")() );
>   }
>
>
> I make no claim about correctness ... I am not familiar enough with the
> low level details of BPL.

It's correct.

> What is certain is that the current code
>
> long array_base::nelements() const
>   {
>     return extract<long>( attr("nelements") );
>   }
>                                           ^^^^
>                                          i.e. without operator()
>
> does not work (numarray 1.0/bpl 1_31/gcc-3.3.3).

I can find no evidence that numeric ever used a different interface.

> The error message:
>
> TypeError: No registered converter was able to produce a C++ rvalue of
> type long from this Python object of type builtin_function_or_method.
>
> seems to be generated because attr("nelements") returns a callable
> PyObject* that cannot be converted to a long.
>
>
> The relevant function from the numarray code (1.0) seems to be
>
> static PyObject *
> _ndarray_nelements(PyArrayObject *self, PyObject  *args)
> {
> 	if (!PyArg_ParseTuple(args, ":nelements"))
> 		return NULL;
> 	return PyInt_FromLong(NA_elements(self));
> }

I'll check in the fix.  Thanks!

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com




More information about the Cplusplus-sig mailing list