🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@da-woods
Copy link
Contributor

@da-woods da-woods commented Aug 4, 2024

Instead of relying of PyObject_GenericSetAttr (which looks to have been updated in Python 3.14 to ban this usage) we instead work out where the type dict is from __dictoffset__ and manipulate that.

Fixes #6323

Instead of relying of PyObject_GenericSetAttr (which looks to
have been updated in Python 3.14 to ban this usage) we instead
work out where the type dict is from __dictoffset__ and
manipulate that.
@da-woods da-woods added this to the 3.1 milestone Aug 4, 2024
Copy link
Contributor

@scoder scoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a smart implementation. Nice.

Comment on lines 699 to 700
// TODO - if we ever support custom metatypes for extension types then
// we have to drop this caching.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

… or use it only for if the type's type is exactly type. That would still catch the majority of extension types. The rest can then hopefully live with a penalty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just changed the comment here for now.

That'd work as a solution, but doesn't seem worth implementing until we need it.

da-woods and others added 2 commits August 4, 2024 18:37
Co-authored-by: scoder <stefan_ml@behnel.de>
and take a bit more care about dictoffset edge cases
(mostly just raising an error for now)
@scoder scoder merged commit 82b2c2b into cython:master Aug 5, 2024
filmor added a commit to pythonnet/pythonnet that referenced this pull request Dec 7, 2025
Python 3.14 introduced a new assertion that prevents us from using
PyObject_GenericSetAttr directly in our meta type. To work around
this, we manipulate the type dict directly.

This workaround is a simplified variant of Cython's workaround from
cython/cython#6325.

The relevant Python change is in
python/cpython#118454
filmor added a commit to pythonnet/pythonnet that referenced this pull request Dec 8, 2025
Python 3.14 introduced a new assertion that prevents us from using
PyObject_GenericSetAttr directly in our meta type. To work around
this, we manipulate the type dict directly.

This workaround is a simplified variant of Cython's workaround from
cython/cython#6325.

The relevant Python change is in
python/cpython#118454
filmor added a commit to pythonnet/pythonnet that referenced this pull request Dec 8, 2025
Python 3.14 introduced a new assertion that prevents us from using
PyObject_GenericSetAttr directly in our meta type. To work around
this, we manipulate the type dict directly.

This workaround is a simplified variant of Cython's workaround from
cython/cython#6325.

The relevant Python change is in
python/cpython#118454
filmor added a commit to pythonnet/pythonnet that referenced this pull request Dec 8, 2025
Python 3.14 introduced a new assertion that prevents us from using
PyObject_GenericSetAttr directly in our meta type. To work around
this, we manipulate the type dict directly.

This workaround is a simplified variant of Cython's workaround from
cython/cython#6325.

The relevant Python change is in
python/cpython#118454
filmor added a commit to pythonnet/pythonnet that referenced this pull request Dec 8, 2025
Python 3.14 introduced a new assertion that prevents us from using
PyObject_GenericSetAttr directly in our meta type. To work around
this, we manipulate the type dict directly.

This workaround is a simplified variant of Cython's workaround from
cython/cython#6325.

The relevant Python change is in
python/cpython#118454
filmor added a commit to pythonnet/pythonnet that referenced this pull request Dec 9, 2025
Python 3.14 introduced a new assertion that prevents us from using
PyObject_GenericSetAttr directly in our meta type. To work around
this, we manipulate the type dict directly.

This workaround is a simplified variant of Cython's workaround from
cython/cython#6325.

The relevant Python change is in
python/cpython#118454
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Cython uses PyObject_GenericSetAttr() on types in Limited API

2 participants