Fix bugs in example found by Georg Brandl.
This commit is contained in:
parent
3fa034da0d
commit
712dd58b08
|
@ -197,7 +197,7 @@ Example:
|
|||
self.member_names.append(key)
|
||||
|
||||
# Call superclass
|
||||
dict.setitem(self, key, value)
|
||||
dict.__setitem__(self, key, value)
|
||||
|
||||
# The metaclass
|
||||
class OrderedClass(type):
|
||||
|
@ -208,12 +208,12 @@ Example:
|
|||
return member_table()
|
||||
|
||||
# The metaclass invocation
|
||||
def __init__(self, name, bases, classdict):
|
||||
def __new__(cls, name, bases, classdict):
|
||||
# Note that we replace the classdict with a regular
|
||||
# dict before passing it to the superclass, so that we
|
||||
# don't continue to record member names after the class
|
||||
# has been created.
|
||||
result = type(name, bases, dict(classdict))
|
||||
result = type.__new__(cls, name, bases, dict(classdict))
|
||||
result.member_names = classdict.member_names
|
||||
return result
|
||||
|
||||
|
|
Loading…
Reference in New Issue