Skip to content

FrozenInstanceError on 3.13+ for reify types with non-frozen bases #1088

Closed
@chrisrink10

Description

@chrisrink10

Since updating to Python 3.13, reify types created with non-frozen bases (such as any subclass of io/IOBase) emit an attrs FrozenInstanceError typically when the Python VM is shutting down (and __del__ is called, which calls self.close() and which attempts to modify the instance via __setattr__). It is not possible to make reify types mutable (not attrs.frozen), so this is not avoidable at the moment.

(reify* :implements [^:abstract ^{:abstract-members #{:read :write}} io/IOBase]
  (read [this n])
  (write [this v]))

The exception being printed is being caught by the Python sys.unraisablehook since it's happening only at shutdown:

Exception ignored in: ReifiedType_6652(_meta=None)
Traceback (most recent call last):
  File "/Users/christopher/Library/Caches/pypoetry/virtualenvs/basilisp-lKTp5Mxg-py3.13/lib/python3.13/site-packages/attr/_make.py", line 551, in _frozen_setattrs
    raise FrozenInstanceError()
attr.exceptions.FrozenInstanceError:

These are also being reported as warnings via PyTest.

I imagine this isn't actually limited to Python 3.13, but only that it's just now being reported on that version.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions