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
finalizer=lambda*a: Nonetry:
sys.set_asyncgen_hooks(firstiter="invalid", finalizer=finalizer)
exceptTypeError: # TypeError due to invalid `firstiter` typecur=sys.get_asyncgen_hooks()
self.assertIsNone(cur.firstiter) # This is not set self.assertIsNone(cur.finalizer) # But this is set
PEP 525 doesn't imply or define partial initialization priority. Since inside of set_asyncgen_hooks is blackbox to user, this is surprising and users are hard to know they have to back up current setup and recover it when TypeError happens.
Inconsistency also cause user experience problem. Current order sys.set_asyncgen_hooks(firstiter="invalid", finalizer=finalizer) causes partial set, but sys.set_asyncgen_hooks(firstiter=finalizer, finalizer="invalid") will not.
Bug report
Bug description:
PEP 525 doesn't imply or define partial initialization priority. Since inside of
set_asyncgen_hooks
is blackbox to user, this is surprising and users are hard to know they have to back up current setup and recover it whenTypeError
happens.Inconsistency also cause user experience problem. Current order
sys.set_asyncgen_hooks(firstiter="invalid", finalizer=finalizer)
causes partial set, butsys.set_asyncgen_hooks(firstiter=finalizer, finalizer="invalid")
will not.CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
The text was updated successfully, but these errors were encountered: