diff options
| author | Rapptz <[email protected]> | 2019-04-15 07:15:28 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2019-04-15 07:16:23 -0400 |
| commit | f71fd33eba797dbb84ee8271bdca47edf6c0e1d2 (patch) | |
| tree | aba1eb027f9c94277d24fb2969efac1c1ee2c2af | |
| parent | Add notes to all relationship endpoints that they don't work on bots. (diff) | |
| download | discord.py-f71fd33eba797dbb84ee8271bdca47edf6c0e1d2.tar.xz discord.py-f71fd33eba797dbb84ee8271bdca47edf6c0e1d2.zip | |
Fix UnboundLocalError when RequestsWebhookAdapter raises an error.
| -rw-r--r-- | discord/webhook.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/discord/webhook.py b/discord/webhook.py index d44a5e94..6343b852 100644 --- a/discord/webhook.py +++ b/discord/webhook.py @@ -137,14 +137,17 @@ class WebhookAdapter: files_to_pass = None url = '%s?wait=%d' % (self._request_url, wait) + maybe_coro = None try: maybe_coro = self.request('POST', url, multipart=multipart, payload=data, files=files_to_pass) finally: - if cleanup is not None: + if maybe_coro is not None and cleanup is not None: if not asyncio.iscoroutine(maybe_coro): cleanup() else: maybe_coro = self._wrap_coroutine_and_cleanup(maybe_coro, cleanup) + + # if request raises up there then this should never be `None` return self.handle_execution_response(maybe_coro, wait=wait) class AsyncWebhookAdapter(WebhookAdapter): |