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


Groups > comp.lang.python > #49378

Re: Problems with subclassing enum34

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Thomas Heller <theller@ctypes.org>
Newsgroups comp.lang.python
Subject Re: Problems with subclassing enum34
Date Fri, 28 Jun 2013 17:25:27 +0200
Lines 29
Message-ID <b35o16Fu6l8U1@mid.individual.net> (permalink)
References <b357q6Fql37U1@mid.individual.net> <mailman.3961.1372432574.3114.python-list@python.org>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net Vj4PMUqXFSrnijQCdnNyQwGdlG2lSHvRivHkK+LPSslQLZt24=
Cancel-Lock sha1:b0wO94qHKOprhaqmdUSCezHToMQ=
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7
In-Reply-To <mailman.3961.1372432574.3114.python-list@python.org>
Xref csiph.com comp.lang.python:49378

Show key headers only | View raw


Am 28.06.2013 17:16, schrieb Ethan Furman:
> On 06/28/2013 03:48 AM, Thomas Heller wrote:
>> trying out the enum34 module.
>>
>> What I want to create is a subclass of enum.Enum that is also based
>> on ctypes.c_int so that I can better use enum instances in ctypes
>> api calls.
>
> Have you tried using enum.IntEnum?  If you were able to pass ints in
>  before, IntEnum should work.

I'm sure that IntEnum works as expected, but I need enums that are
subclasses of ctypes.c_int (so that argument type checking and return
value conversions in ctypes api calls work).

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.

Thomas

Back to comp.lang.python | Previous | NextPrevious in thread | Next 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