This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: xml.dom.minidom.Element.ownerDocument is hidden
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.4
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: flox, krocard, loewis, r.david.murray
Priority: normal Keywords:

Created on 2015-02-10 19:30 by krocard, last changed 2022-04-11 14:58 by admin.

Messages (2)
msg235700 - (view) Author: Kevin Rocard (krocard) Date: 2015-02-10 19:30
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).
msg236366 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-02-21 15:04
It looks like the __slots__ declaration on Node was missed when the other slots changes were made (by MvL in 3931f043b79a).  Note that the Node base class (xml.dom.Node) has a __slots__ declaration, but it was added after MvL's patch (by Florent in 49c5511b234a).

Changing this now may have backward compatibility issues, though.
History
Date User Action Args
2022-04-11 14:58:12adminsetgithub: 67624
2020-11-13 06:13:51vapiersettitle: xml.dom.minidom.Element.ownerDocument is hiden -> xml.dom.minidom.Element.ownerDocument is hidden
2015-02-21 15:04:19r.david.murraysetnosy: + loewis, r.david.murray, flox
messages: + msg236366
2015-02-10 19:30:43krocardcreate