From 98013be7977c613d8a1c5f0446a73d100ccc7b17 Mon Sep 17 00:00:00 2001 From: Jeremy Hylton Date: Fri, 12 Jul 2002 15:42:10 +0000 Subject: [PATCH] Get the meta class inheritance right. --- Demo/newmetaclasses/Eiffel.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Demo/newmetaclasses/Eiffel.py b/Demo/newmetaclasses/Eiffel.py index 3e68611f56a..1dd7e6c17f0 100644 --- a/Demo/newmetaclasses/Eiffel.py +++ b/Demo/newmetaclasses/Eiffel.py @@ -4,6 +4,11 @@ from new import function class EiffelBaseMetaClass(type): + def __new__(meta, name, bases, dict): + meta.convert_methods(dict) + return super(EiffelBaseMetaClass, meta).__new__(meta, name, bases, + dict) + def convert_methods(cls, dict): """Replace functions in dict with EiffelMethod wrappers. @@ -30,10 +35,6 @@ class EiffelBaseMetaClass(type): class EiffelMetaClass1(EiffelBaseMetaClass): # an implementation of the "eiffel" meta class that uses nested functions - def __new__(meta, name, bases, dict): - meta.convert_methods(dict) - return super(EiffelMetaClass1, meta).__new__(meta, name, bases, dict) - def make_eiffel_method(func, pre, post): def method(self, *args, **kwargs): if pre: @@ -80,7 +81,7 @@ class EiffelDescriptor(object): self._post(inst, x, *args, **kwargs) return x -class EiffelMetaClass2(EiffelMetaClass1): +class EiffelMetaClass2(EiffelBaseMetaClass): # an implementation of the "eiffel" meta class that uses descriptors make_eiffel_method = EiffelDescriptor