Closed ThiefMaster closed 1 year ago
Not sure if this is expected, but if seems weird that it serializes differently depending on the Python version.
import sys import yaml try: from enum import ReprEnum except ImportError: from enum import Enum as ReprEnum class MyEnum(int, ReprEnum): foo = 123 print('Python version:', ''.join(map(str, sys.version_info[:3]))) print(yaml.dump({'test': MyEnum.foo}))
Python version: 3.10.12 test: !!python/object/apply:__main__.MyEnum - 123
Python version: 3.11.4 test: !!python/object/apply:builtins.getattr - !!python/name:__main__.MyEnum '' - foo
FWIW it also happens with a normal Enum instead of ReprEnum.
OK this looks like a bug in Python that got fixed in python/cpython#105348 (the __reduce_ex__ change in that PR), but isn't part of a 3.11 point release yet..
__reduce_ex__
Not sure if this is expected, but if seems weird that it serializes differently depending on the Python version.
Script to reproduce (using PyYAML==6.0)
3.10 output:
3.11 output:
FWIW it also happens with a normal Enum instead of ReprEnum.