IcePy: Accept integers where floats are expected

cebixcebix Member Christian BauerOrganization: AREVAProject: Diagnostics frontend for industrial I&C
(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

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    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
Sign In or Register to comment.