Archived

This forum has been archived. Please start a new discussion on GitHub.

IcePy: Accept integers where floats are expected

(Using Ice 3.3.1 on Linux)

Consider this Slice definition:
module Demo {
    struct Value {
        float v;
    };

    interface Printer {
        void printFloat(float f);
        void printValue(Value v);
    };
};
In a Python client it's not possible to call printFloat() with an integer argument or use an integer value for the data member of the Value structure:
>>> printer.printFloat(42)
ValueError: invalid value for argument 1 in operation `printFloat'
>>> v = Demo.Value(42)
>>> printer.printValue(v)
ValueError: invalid value for ::Demo::Value member `v'
Such a strict type validation is very unusual and inconvenient for Python. IMHO, IcePy should implicitly convert integers to floats in these cases.

Comments

  • mes
    mes California
    cebix wrote: »
    Such a strict type validation is very unusual and inconvenient for Python. IMHO, IcePy should implicitly convert integers to floats in these cases.
    Agreed, we'll fix this.

    Thanks,
    Mark