Changeset 13844


Ignore:
Timestamp:
Oct 24, 2019 4:48:57 PM (4 weeks ago)
Author:
aramle
Message:

#5819 Updating to Python 3 compatibility.

File:
1 edited

Legend:

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

    r13832 r13844  
    41974197            self.set_integer([ref], [value])
    41984198        elif type == FMIL.fmi2_base_type_enum:
    4199             if isinstance(value, str):
     4199            if isinstance(value, str) or isinstance(value, bytes):
    42004200                enum_type = self.get_variable_declared_type(variable_name)
    4201                 enum_values = {v[0]: k for k, v in enum_type.items.items()}
     4201                enum_values = {encode(v[0]): k for k, v in enum_type.items.items()}
    42024202                try:
    4203                     self.set_integer([ref], [enum_values[value]])
     4203                    self.set_integer([ref], [enum_values[encode(value)]])
    42044204                except KeyError:
    42054205                    raise FMUException("The value '%s' is not in the list of allowed enumeration items for variable '%s'. Allowed values: %s'"%(value, variable_name, ", ".join(enum_values.keys())))
Note: See TracChangeset for help on using the changeset viewer.