Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:184.172': 0.09; 'received:gator410.hostgator.com': 0.09; 'thus,': 0.09; '~ethan~': 0.09; 'bug': 0.12; '__new__': 0.16; 'bases,': 0.16; 'enum': 0.16; 'metaclass': 0.16; 'metaclasses': 0.16; 'received:gateway01.websitewelcome.com': 0.16; 'subject:Problems': 0.16; 'typeerror:': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'solution.': 0.20; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'mention': 0.26; 'skip:" 40': 0.26; 'skip:_ 20': 0.27; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'forgot': 0.30; 'robert': 0.30; "i'm": 0.30; 'work.': 0.31; 'that.': 0.31; 'ctypes': 0.31; 'file': 0.32; 'class': 0.32; '(most': 0.33; 'problem': 0.35; 'subject:with': 0.35; 'but': 0.35; 'there': 0.35; "didn't": 0.36; 'charset:us-ascii': 0.36; 'two': 0.37; 'to:addr:python-list': 0.38; 'skip:_ 40': 0.38; 'recent': 0.39; 'skip:_ 30': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'received:173': 0.61; 'simply': 0.61; 'chance': 0.65; 'thomas': 0.65; 'received:69.56': 0.68 Date: Fri, 28 Jun 2013 10:09:49 -0700 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Problems with subclassing enum34 References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([173.12.184.233]) [173.12.184.233]:43919 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1372440712 news.xs4all.nl 15964 [2001:888:2000:d::a6]:47663 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:49384 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 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~