[New-bugs-announce] [issue23673] IntEnum is unpicklable by previous Python versions

Ethan Furman report at bugs.python.org
Sun Mar 15 16:10:45 CET 2015

New submission from Ethan Furman:

IntEnum is advertised as being a drop-in replacement for integer contants; however this fails in the case of unpickling on previous Python versions.

This occurs because when a pickle is created the module, class, and value are stored -- but those don't exist prior to Python 3.4.

One solution is to modify IntEnum to pickle just like a plain int would, but this has the serious disadvantage of losing the benefits of IntEnum on Python versions that support it.

Another solution is to use Serhiy's idea of pickling by name; this would store the module and name to look up in that madule, and this works on all Python versions that have that constant: on Python 3.3 socket.AF_INET returns an integerer (2, I think), and on Python 3.4+ it returns the AF_INET AddressFamily member.

assignee: ethan.furman
keywords: 3.4regression
messages: 238148
nosy: barry, eli.bendersky, ethan.furman, serhiy.storchaka
priority: normal
severity: normal
stage: test needed
status: open
title: IntEnum is unpicklable by previous Python versions
type: behavior
versions: Python 3.4, Python 3.5

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list