SAP / PyRFC

Asynchronous, non-blocking SAP NW RFC SDK bindings for Python
http://sap.github.io/PyRFC
Apache License 2.0
500 stars 132 forks source link

set_locale_radix ignored #371

Open tidenhub opened 2 months ago

tidenhub commented 2 months ago

I have set the locals to a language with a comma as a decimal separator, like "de_DE".

If I set set_locale_radix(".") I would expect that {"RFCFLOAT": "1.2"} could be parsed without errors.

But I'm getting the error pyrfc._exception.ExternalRuntimeError: 22 (rc=22): key=RFC_CONVERSION_FAILURE, message=Cannot convert string value 1.2 at position 1 for the field RFCFLOAT to type RFCTYPE_FLOAT [MSG: class=, type=, number=, v1-4:=;;;]

To Reproduce Describe the steps to reproduce the behavior, including test script.

        setlocale(LC_ALL, "de_DE", )
        set_locale_radix(".")
        IMPORTSTRUCT = {"RFCFLOAT": "1.2"}
        output = client.call(
            "STFC_STRUCTURE",
            IMPORTSTRUCT=IMPORTSTRUCT,
        )["ECHOSTRUCT"]
        assert output["RFCFLOAT"] == 1.2

Aditional informaiton If I replace set_locale_radix with locale.setlocale(locale.LC_NUMERIC, "en_GB.UTF-8") the script runs without any errors.

Environment

hkroeber commented 1 month ago

Hi, that issues has been already seen in an older pyrfc version and fixed. Please see https://github.com/SAP/PyRFC/issues/142.

And yes, I can confirm the issue for version 3.3.0 too. Hagen