#21 Compiler error with gcc


When assigning an item of a Py::Tuple to e.g. a Py::Int, then I encounter a compiler error with gcc.

For example:

static PyObject *
some_module_method(PyObject* self, PyObject* args)
PyObject* object; // a tuple inside a tuple
if (!PyArg_ParseTuple(args, "O", &object))
return NULL;

try {
Py::Tuple tuple(object);
Py::Int x = tuple[0]; // => compiler error
Py::Int y = tuple[1];
// ...
return Py::new_reference_to(Py::None());
} catch (const Py::Exception&) {
return NULL;

I have compiled this code with gcc 3.4, 4.0 and 4.2 and all of them failed with the message:
conversion from 'Py::seqref<Py::Object>' to non-scalar type 'Py::Int' requested

However, with MS compiler (Visual Studio 8) the above code compiled successfully.

If I write 'const Py::Tuple (object);' then the error with 4.x disappear but with 3.4 there is still the same error.

And if I write Py::Int x(tuple[0]); Py::Int y(tuple[1]); all compiler errors disappear.

This error probably concerns all sequence classes when assigning an item to another Py::Object derived class.


  • Werner Mayer

    Werner Mayer - 2007-04-28
    • assigned_to: nobody --> barry-scott
  • Barry Alan Scott

    I'm not aware of this error being in the current source

  • Barry Alan Scott

    • status: open --> closed-out-of-date

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks