You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
3.12 regression: cannot create weak reference to 'typing.TypeVar' object #106403
I'm assuming it's an unintentional side effect of the PEP-695 implementation? Unfortunately I don't have time to investigate right now, let me know if I should.
The new typing.TypeAliasType is also not weakrefable:
>>> type T = int
>>> weakref.ref(T)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot create weak reference to 'typing.TypeAliasType' object
But neither is the existing UnionType:
>>> weakref.ref(int | str)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot create weak reference to 'types.UnionType' object
I suspect that this might cause problems with cloudpickle when executing interactively defined functions with type annotations in their signatures on remote Python workers (e.g. in Dask, Ray or PySpark / databricks).
I merged my PR that re-adds weakref support for TypeVars. I haven't tried to debug the segfaults in the cloudpickle tests, but let me know if those can be minified to something that shows the issue is in CPython.
Closing this as the original report is (believed to be) fixed. If the other cloudpickle issues are caused by bugs in 3.12 it probably deserves its own issue.
Activity
JelleZijlstra commentedon Jul 4, 2023
Fixing.
The new
typing.TypeAliasTypeis also not weakrefable:But neither is the existing UnionType:
So maybe that's fine?
pythongh-106403: Restore weakref support for TypeVar and friends
ogrisel commentedon Jul 6, 2023
Thanks @JelleZijlstra!
I suspect that this might cause problems with
cloudpicklewhen executing interactively defined functions with type annotations in their signatures on remote Python workers (e.g. in Dask, Ray or PySpark / databricks).I did not have time to investigate the details myself yet but @musicinmybrain tried to test your fix in cloudpickle in cloudpipe/cloudpickle#507 (comment) and there are still segfaults to debug.
pythongh-106403: Restore weakref support for TypeVar and friends (pyt…
gh-106403: Restore weakref support for TypeVar and friends (#106418)
JelleZijlstra commentedon Jul 11, 2023
I merged my PR that re-adds weakref support for TypeVars. I haven't tried to debug the segfaults in the cloudpickle tests, but let me know if those can be minified to something that shows the issue is in CPython.
[3.12] gh-106403: Restore weakref support for TypeVar and friends (GH…
Yhg1s commentedon Jul 31, 2023
Closing this as the original report is (believed to be) fixed. If the other cloudpickle issues are caused by bugs in 3.12 it probably deserves its own issue.