Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

contextlib.ContextManager doesn't contain__slots__ = () #105726

Closed
Labels
type-bugAn unexpected behavior, bug, or error
@erezinman

Description

@erezinman

Python's ABCs should have__slots__ attributes to not interfere with slotting in derived classes (especially when the class has no members). However, it is not the case forcontextlib.ContextManager (as for othercontextlib ABCs):

fromtypingimportContextManagerclassA(ContextManager[int]):__slots__= ()__enter__=__exit__=lambda*args:NoneA().a=1# No exception

ChangingContextManager toMutableMapping, for example (and setting relevant dunders), does raise an exception.

Observed on Ubuntu 20.04 and Python 3.9.16.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp