Changeset 13832


Ignore:
Timestamp:
Oct 24, 2019 7:44:11 AM (4 weeks ago)
Author:
randersson
Message:

#5819 Reverted back fmi_util and fixed the encoding of the list in the methods set_string(...) instead.

Location:
PyFMI/trunk/src/pyfmi
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • PyFMI/trunk/src/pyfmi/fmi.pyx

    r13828 r13832  
    16201620                'The length of valueref and values are inconsistent.')
    16211621       
    1622         values = encode(values)
     1622        values = [encode(item) for item in values]
    16231623        for i in range(val_ref.size):
    16241624            val[i] = values[i]
     
    41714171                'The length of valueref and values are inconsistent.')
    41724172
    4173         values = encode(values)
     4173        values = [encode(item) for item in values]
    41744174        for i in range(val_ref.size):
    41754175            val[i] = values[i]
  • PyFMI/trunk/src/pyfmi/fmi_util.pyx

    r13823 r13832  
    3737
    3838cpdef decode(x):
    39     if isinstance(x, list):
    40         return [item.decode() if python3_flag else item for item in x]
     39    if python3_flag:
     40        return x.decode()
    4141    else:
    42         return x.decode() if python3_flag else x
     42        return x
    4343
    4444cpdef encode(x):
    45     if isinstance(x, str):
    46         return x.encode() if python3_flag else x.encode("utf-8")
    47     elif isinstance(x, list):
    48         return [item.encode() if python3_flag else item.encode("utf-8") for item in x]
     45    if python3_flag:
     46        if isinstance(x, str):
     47            return x.encode()
     48        else:
     49            return x
    4950    else:
    50         return x if python3_flag else x.encode("utf-8")
     51        return x.encode("utf-8")
    5152
    5253def enable_caching(obj):
Note: See TracChangeset for help on using the changeset viewer.