Bug report
If the row is referenced before assignment an error is thrown.
Traceback
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 390, in start
resp = await self._request_handler(request)
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 366, in _handle
resp = await handler(request)
File "pfurl/__main__.py", line 174, in hash_redirect
return aiohttp.web.HTTPFound(row[0])
UnboundLocalError: local variable 'row' referenced before assignment
Resolution
Rewrite to ensure the row is not referenced before assignment in the following function.
async def hash_redirect(request):
statement = 'select url from pfurl where hash=%s'
hash = request.match_info.get('hash')
ret = []
async with request.app['pool'].acquire() as connection:
async with connection.cursor() as cursor:
await cursor.execute(
statement,
(hash,)
)
async for row in cursor:
ret.append(row)
return aiohttp.web.HTTPFound(row[0])
Bug report
If the row is referenced before assignment an error is thrown.
Traceback
Resolution
Rewrite to ensure the row is not referenced before assignment in the following function.