cpython: 365b5e6163a6 (original) (raw)

Mercurial > cpython

changeset 101662:365b5e6163a6

signal, socket, and ssl module IntEnum constant name lookups now return a consistent name for values having multiple names. Ex: signal.Signals(6) now refers to itself as signal.SIGALRM rather than flipping between that and signal.SIGIOT based on the interpreter's hash randomization seed. This helps finish issue27167. [#27167]

Gregory P. Smith greg@krypto.org [Google Inc.]
date Fri, 03 Jun 2016 19:14:52 +0000
parents 050e5f803999
children 8b6b6add8e47
files Lib/enum.py Lib/test/test_enum.py Misc/NEWS
diffstat 3 files changed, 49 insertions(+), 2 deletions(-)[+] [-] Lib/enum.py 10 Lib/test/test_enum.py 36 Misc/NEWS 5

line wrap: on

line diff

--- a/Lib/enum.py +++ b/Lib/enum.py @@ -550,8 +550,14 @@ class Enum(metaclass=EnumMeta): source = vars(source) else: source = module_globals

--- a/Lib/test/test_enum.py +++ b/Lib/test/test_enum.py @@ -1768,5 +1768,41 @@ class MiscTestCase(unittest.TestCase): support.check__all__(self, enum) +# These are unordered here on purpose to ensure that declaration order +# makes no difference. +CONVERT_TEST_NAME_D = 5 +CONVERT_TEST_NAME_C = 5 +CONVERT_TEST_NAME_B = 5 +CONVERT_TEST_NAME_A = 5 # This one should sort first. +CONVERT_TEST_NAME_E = 5 +CONVERT_TEST_NAME_F = 5 + +class TestIntEnumConvert(unittest.TestCase):

+

+ + if name == 'main': unittest.main()

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -27,6 +27,11 @@ Core and Builtins Library ------- +- signal, socket, and ssl module IntEnum constant name lookups now return a