mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
Issue #24254: Preserve class attribute definition order.
This commit is contained in:
parent
4565986138
commit
92a6c170e6
18 changed files with 568 additions and 189 deletions
|
|
@ -25,8 +25,11 @@ CoroutineType = type(_c)
|
|||
_c.close() # Prevent ResourceWarning
|
||||
|
||||
class _C:
|
||||
_nsType = type(locals())
|
||||
def _m(self): pass
|
||||
MethodType = type(_C()._m)
|
||||
# In CPython, this should end up as OrderedDict.
|
||||
_DefaultClassNamespaceType = _C._nsType
|
||||
|
||||
BuiltinFunctionType = type(len)
|
||||
BuiltinMethodType = type([].append) # Same as BuiltinFunctionType
|
||||
|
|
@ -85,7 +88,7 @@ def prepare_class(name, bases=(), kwds=None):
|
|||
if hasattr(meta, '__prepare__'):
|
||||
ns = meta.__prepare__(name, bases, **kwds)
|
||||
else:
|
||||
ns = {}
|
||||
ns = _DefaultClassNamespaceType()
|
||||
return meta, ns, kwds
|
||||
|
||||
def _calculate_meta(meta, bases):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue