Issue 23436: xml.dom.minidom.Element.ownerDocument is hidden (original) (raw)

Extracted from xml.dom.minidom:

Node(...):
   ...
   ownerDocument = None
   ...

Element(Node):
    __slots__=('ownerDocument', ...)
    ...

As Element declares an ownerDocument attribute in slots, Node's ownerDocument attribute is hidden:

class B: b=1;
class D(B): __slots__={'b'}
D().b -> AttributeError

This leads to a strange behaviour were accessing a base attribute fails with an attribute error.

Should the Node.ownerDocument attribute not be removed? Or its name removed from the Element.slots list? Ie have the attribute in the base or the derivative, but not both.

Independent note: <https://docs.python.org/3/reference/datamodel.html#slots> says:

When inheriting from a class without slots [Node], the dict attribute of that class will always be accessible, so a slots definition in the subclass [Element] is meaningless.

So as for as I understand Element.slots does not reduce the Element() footprint (it was introduced for that).