We need to use a different mechanism for representing enums to keep compatibility with python 2. Reported by @Matrixcoffee.