Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xml.dom.minidom.Element.ownerDocument is hidden #67624

Open
krocard mannequin opened this issue Feb 10, 2015 · 2 comments
Open

xml.dom.minidom.Element.ownerDocument is hidden #67624

krocard mannequin opened this issue Feb 10, 2015 · 2 comments
Labels
stdlib Python modules in the Lib dir topic-XML type-feature A feature request or enhancement

Comments

@krocard
Copy link
Mannequin

krocard mannequin commented Feb 10, 2015

BPO 23436
Nosy @loewis, @bitdancer, @florentx

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2015-02-10.19:30:43.712>
labels = ['type-feature', 'library']
title = 'xml.dom.minidom.Element.ownerDocument is hidden'
updated_at = <Date 2020-11-13.06:13:51.337>
user = 'https://bugs.python.org/krocard'

bugs.python.org fields:

activity = <Date 2020-11-13.06:13:51.337>
actor = 'vapier'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2015-02-10.19:30:43.712>
creator = 'krocard'
dependencies = []
files = []
hgrepos = []
issue_num = 23436
keywords = []
message_count = 2.0
messages = ['235700', '236366']
nosy_count = 4.0
nosy_names = ['loewis', 'r.david.murray', 'flox', 'krocard']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue23436'
versions = ['Python 3.4']

@krocard
Copy link
Mannequin Author

krocard mannequin commented Feb 10, 2015

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).

@krocard krocard mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Feb 10, 2015
@bitdancer
Copy link
Member

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.

@vapier vapier mannequin changed the title xml.dom.minidom.Element.ownerDocument is hiden xml.dom.minidom.Element.ownerDocument is hidden Nov 13, 2020
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir topic-XML type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants