Compare commits

...

2 Commits

Author SHA1 Message Date
Miss Islington (bot) fbffda25b4
bpo-42727: [Enum] use super() and include **kwds (GH-23927)
for multiple inheritance support:

use super().new
pass **kwds to super().new
(cherry picked from commit 786d97a66c)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
2020-12-25 08:07:30 -08:00
Miss Islington (bot) 51f5029146
bpo-42734: Fix crasher bogus_code_obj.py (GH-23939)
It did not work because the signature of code object constructor
was changed. Also, it used old format of bytecode (pre-wordcode).
(cherry picked from commit 954a7427ba)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2020-12-25 07:22:56 -08:00
2 changed files with 3 additions and 3 deletions

View File

@ -227,10 +227,10 @@ class EnumMeta(type):
# create our new Enum type # create our new Enum type
if bases: if bases:
bases = (_NoInitSubclass, ) + bases bases = (_NoInitSubclass, ) + bases
enum_class = type.__new__(metacls, cls, bases, classdict) enum_class = super().__new__(metacls, cls, bases, classdict, **kwds)
enum_class.__bases__ = enum_class.__bases__[1:] #or (object, ) enum_class.__bases__ = enum_class.__bases__[1:] #or (object, )
else: else:
enum_class = type.__new__(metacls, cls, bases, classdict) enum_class = super().__new__(metacls, cls, bases, classdict, **kwds)
old_init_subclass = getattr(enum_class, '__init_subclass__', None) old_init_subclass = getattr(enum_class, '__init_subclass__', None)
# and restore the new one (if there was one) # and restore the new one (if there was one)
if new_init_subclass is not None: if new_init_subclass is not None:

View File

@ -14,6 +14,6 @@ the user build or load random bytecodes anyway. Otherwise, this is a
import types import types
co = types.CodeType(0, 0, 0, 0, 0, b'\x04\x71\x00\x00', co = types.CodeType(0, 0, 0, 0, 0, 0, b'\x04\x00\x71\x00',
(), (), (), '', '', 1, b'') (), (), (), '', '', 1, b'')
exec(co) exec(co)