Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
Bug description:
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 setself.assertIsNone(cur.finalizer)# But this is set
PEP 525 doesn't imply or define partial initialization priority. Since inside ofset_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 ordersys.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