Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #49384

Re: Problems with subclassing enum34

Date 2013-06-28 10:09 -0700
From Ethan Furman <ethan@stoneleaf.us>
Subject Re: Problems with subclassing enum34
References <b357q6Fql37U1@mid.individual.net> <mailman.3961.1372432574.3114.python-list@python.org> <b35o16Fu6l8U1@mid.individual.net> <b35odpFu8igU1@mid.individual.net>
Newsgroups comp.lang.python
Message-ID <mailman.3966.1372440712.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 06/28/2013 08:32 AM, Thomas Heller wrote:
> Am 28.06.2013 17:25, schrieb Thomas Heller:
>> Robert Kern:
>>
>>>
>>> enum.EnumMeta uses super() in its __new__() implementation but
>>> _ctypes.PyCSimpleType doesn't. Thus, only
>>> _ctypes.PyCSimpleType.__new__() gets a chance to run. Switching the
>>> order of the two might work.
>>>
>>
>> Robert found the problem but I'm unsure if there is a solution.
>> Also I'm unsure whether this is a bug in ctypes or in enum or if
>> they are simply incompatible.
>
> I forgot to mention that switching the order of metaclasses didn't work.

Here's the traceback:

Traceback (most recent call last):
   File "ct.py", line 7, in <module>
     class MyEnum(ctypes.c_int, Enum):
   File "/home/ethan/source/enum/enum/py2_enum.py", line 149, in __new__
     enum_class = super(EnumMeta, metacls).__new__(metacls, cls, bases, classdict)
TypeError: Error when calling the metaclass bases
     _ctypes.PyCSimpleType.__new__(MyEnum_meta) is not safe, use type.__new__()

Not sure how to fix that.

--
~Ethan~

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Problems with subclassing enum34 Thomas Heller <theller@ctypes.org> - 2013-06-28 12:48 +0200
  Re: Problems with subclassing enum34 Robert Kern <robert.kern@gmail.com> - 2013-06-28 12:16 +0100
  Re: Problems with subclassing enum34 88888 Dihedral <dihedral88888@gmail.com> - 2013-06-28 04:52 -0700
  Re: Problems with subclassing enum34 Ethan Furman <ethan@stoneleaf.us> - 2013-06-28 08:16 -0700
    Re: Problems with subclassing enum34 Thomas Heller <theller@ctypes.org> - 2013-06-28 17:25 +0200
      Re: Problems with subclassing enum34 Thomas Heller <theller@ctypes.org> - 2013-06-28 17:32 +0200
        Re: Problems with subclassing enum34 Robert Kern <robert.kern@gmail.com> - 2013-06-28 17:17 +0100
        Re: Problems with subclassing enum34 Ethan Furman <ethan@stoneleaf.us> - 2013-06-28 10:09 -0700

csiph-web