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 <rep...@bugs.python.org>
<http://bugs.python.org/issue23673>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to