[New-bugs-announce] [issue1734] no effect if metaclass modifies dict

L. Peter Deutsch report at bugs.python.org
Fri Jan 4 06:50:39 CET 2008


New submission from L. Peter Deutsch:

In the following, dir(Node) should include the name 'z', and Node.z
should be 'Node'. However, dir(Node) does not include 'z', and Node.z is
undefined (AttributeError). This is directly contrary to the Python
documentation, which says "metaclasses can modify dict".

class MetaNode(type):
    def __init__(cls, name, bases, cdict):
        cdict['z'] = name
        type.__init__(name, bases, cdict)
class Node(object):
    __metaclass__ = MetaNode

print dir(Node)
print Node.z

----------
components: Interpreter Core
messages: 59216
nosy: lpd
severity: normal
status: open
title: no effect if metaclass modifies dict
versions: Python 2.5

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1734>
__________________________________


More information about the New-bugs-announce mailing list