python / typing_extensions

Backported and experimental type hints for Python
Other
446 stars 110 forks source link

Make sure `isinstance(typing_extensions.ParamSpec("P"), typing.TypeVar)` is unaffected by `sys.setprofile()` #407

Closed AlexWaygood closed 6 months ago

AlexWaygood commented 6 months ago

Fixes #318. The workaround here is to avoid the super() call -- the super() call accesses the __class__ variable from the __init__ method, which due to a CPython bug on Python <=3.10 means that __class__ is removed from ParamSpec.__dict__ if a profiling function has been set.

JelleZijlstra commented 6 months ago

The 4.12.0 release should go out today, do you think it's better to merge this in now or wait for the next release? The change seems pretty safe so I think it's fine to merge now in the RC phase.

AlexWaygood commented 6 months ago

The 4.12.0 release should go out today, do you think it's better to merge this in now or wait for the next release? The change seems pretty safe so I think it's fine to merge now in the RC phase.

Oh shoot, sorry -- I merged before seeing this.

I think it's okay to put it into the next release; I agree that this change seems pretty safe. But I also don't think that this issue affects many people, so I would also be fine with cutting the release based on the commit prior to this.