Skip to content

in xml.dom.minidom, Node and DocumentLS appear to be missing __slots__ #90405

Closed as not planned

Description

@ariebovenberg
BPO 46247
Nosy @ariebovenberg

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 2022-01-03.18:41:15.874>
labels = ['library', '3.9', '3.10', '3.11']
title = 'in xml.dom.minidom, Node and DocumentLS appear to be missing __slots__'
updated_at = <Date 2022-01-14.23:31:22.801>
user = 'https://github.com/ariebovenberg'

bugs.python.org fields:

activity = <Date 2022-01-14.23:31:22.801>
actor = 'eric.araujo'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2022-01-03.18:41:15.874>
creator = 'ariebovenberg'
dependencies = []
files = []
hgrepos = []
issue_num = 46247
keywords = []
message_count = 1.0
messages = ['409605']
nosy_count = 1.0
nosy_names = ['ariebovenberg']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue46247'
versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

Activity

  1. ariebovenberg commented on Jan 3, 2022

    ariebovenbergmannequin
    MannequinAuthor

    (as instructed in bpo-46244, I've created this ticket)

    The classes Node and DocumentLS don't define __slots__, but a number of subclasses do.
    This appears to be a mistake.

    If so, I'd like to create a PR to fix it.

  2. added
    3.11only security fixes
    stdlibStandard Library Python modules in the Lib/ directory
    on Jan 3, 2022
  3. transferred this issue fromon Apr 10, 2022
  4. serhiy-storchaka commented on Aug 30, 2026

    @serhiy-storchaka
    Member

    It is not an oversight that can be corrected by adding __slots__. Node cannot have a non-empty __slots__ at all, because DocumentType inherits from both it and Identified ("multiple bases have instance lay-out conflict"), and DocumentType, Entity, Notation, DocumentFragment and Document use class attributes as defaults for attributes which are then set per instance, which __slots__ does not allow. Every such class would need a complete slot list and explicit initialization.

    It would also break code which sets its own attributes on nodes, and setUserData() which stores them itself. Nodes are weak referenceable now, so __weakref__ would have to be added as well, which costs 8 bytes of what is saved.

    It is better to fix the general problem instead: gh-135385 (PR #156656) does not reserve inline values for attributes stored in slots, which reduces an element from 328 to 232 bytes, without changing minidom and without breaking anything. The rest of the difference does not justify the above. Closing as not planned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-XML

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions