The prior changes to use of return in finally (#9981) are now
insufficient. Without disclosing their intent when raising the issue,
this was used by them as part of justifying a SyntaxError for working
code outside of the normal process for adding errors, and with it
presenting to end users in a way that breaks downstream user's existing CI
While making the change, I've continued to not log errors like
CancellationError or TimeoutError to users here by default, as it is not an error
they need to be aware of during shutdown given the limited kinds of
BaseException that could raise in this context, see: #9984 for prior
analysis. I've added a debug log should anyone want access to this kind
of failure while debugging gateway close, but due to how asyncio
shutdown happens, this is unlikely to ever log anything useful even in a
library debugging context.
Specifically reraise KeyboardInterrupt, SystemExit
Swallow other BaseExceptions due to the way the standard library uses
them and the intent of this function
This provides paths for users to handle two entirely seperate issues
- Alternative fix for #9870
- Allows handling of windows sslcontext issues without a global
truststore.inject_into_ssl() use
This wraps the closing behavior in a task. Subsequent callers of
.close() now await that same close finishing rather than short
circuiting. This prevents a user-called close outside of __aexit__ from
not finishing before no longer having a running event loop.
Why discord did it this way instead of as an integer bitfield like everything
reasonable is unknowable, but this does less work to get to the same result.
Add comment detailing what many would find unreadbale
This changes the type information of check decorators to return a
protocol representing that the decorator leaves the underlying object
unchanged while having a .predicate attribute.
resolves#7949
Adds an efficient way to check if a member has a role by ID.
This is done in a way consistent with the existing user API of the
library.
The more debated Member.has_role_id/has_role is intentionally not
included for review at this time given the heavy bikeshedding of it.
- fixes 4087
- This intentionally uses some internals in both Member.roles and
Member.top_role to retain as much performance as possible while
removing the cache
This adds some implicit permission handling for `discord.VoiceChannel.permissions_for`
This is not documented behavior in discord's developer documentation, but it can easily be verified as correct.