From 821f33f5d1821f260bb79d9d0ee1189c989f8aad Mon Sep 17 00:00:00 2001 From: Phxntxm Date: Fri, 9 Dec 2016 21:34:17 -0600 Subject: [PATCH] Corrected how to wrap the BytesIO object --- cogs/utils/utilities.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/cogs/utils/utilities.py b/cogs/utils/utilities.py index 822eeab..300ba85 100644 --- a/cogs/utils/utilities.py +++ b/cogs/utils/utilities.py @@ -54,15 +54,12 @@ def find_command(bot, command): async def download_image(url): """Returns a file-like object based on the URL provided""" headers = {'User-Agent': config.user_agent} - try: - # Simply download the image - with aiohttp.ClientSession(headers=headers) as session: - async with session.get(url) as r: - image_bytes = r.read() - # Then wrap it in a BytesIO object, to be used like an actual file - return io.BytesIO(image_bytes) - except: - return + # Simply download the image + with aiohttp.ClientSession(headers=headers) as session: + async with session.get(url) as r: + # Then wrap it in a BytesIO object, to be used like an actual file + image = io.BytesIO(await r.read()) + return image async def update_records(key, winner, loser): # We're using the Harkness scale to rate