oddluck / limnoria-plugins

Limnoria plugins I wrote or forked.
Do What The F*ck You Want To Public License
39 stars 17 forks source link

YouTube: UnboundLocalError while handling error #32

Closed progval closed 3 years ago

progval commented 3 years ago

Hi, someone on #supybot just posted this error:

Dec 01 10:29:48 sturtz.cf SturtzBot[1296]:   File "/usr/lib/python3/dist-packages/supybot/callbacks.py", line 1300, in callCommand
Dec 01 10:29:48 sturtz.cf SturtzBot[1296]:     method(irc, msg, *args, **kwargs)
Dec 01 10:29:48 sturtz.cf SturtzBot[1296]:   File "/usr/lib/python3/dist-packages/supybot/commands.py", line 1109, in newf
Dec 01 10:29:48 sturtz.cf SturtzBot[1296]:     f(self, irc, msg, args, *state.args, **state.kwargs)
Dec 01 10:29:48 sturtz.cf SturtzBot[1296]:   File "/NSCS/bots/plugins/YouTube/plugin.py", line 142, in yt
Dec 01 10:29:48 sturtz.cf SturtzBot[1296]:     video_id = self.dosearch(query, msg.channel)
Dec 01 10:29:48 sturtz.cf SturtzBot[1296]:   File "/NSCS/bots/plugins/YouTube/plugin.py", line 80, in dosearch
Dec 01 10:29:48 sturtz.cf SturtzBot[1296]:     "YouTube: Error retrieving data from API: %s" % request.content.decode()
Dec 01 10:29:48 sturtz.cf SturtzBot[1296]: UnboundLocalError: local variable 'request' referenced before assignment
Dec 01 10:29:48 sturtz.cf SturtzBot[1296]: ERROR 2020-12-01T10:29:48 Exception id: 0xc0473

I'm guessing this happens when utils.web.getUrl(api_url).decode() itself crashes; you should probably move it out of this try block into its own.

oddluck commented 3 years ago

Fixed in https://github.com/oddluck/limnoria-plugins/commit/db51fe140407b3ac974153cb1477c256bdefd790