shizmob / pydle

An IRCv3-compliant Python 3 IRC library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IRCv3 tags cause crash in handler loop

kenneaal opened this issue · comments

Something(TM) seems to be going wrong with IRCv3 tags - most likely the reply tag - which causes pydle to crash its handler loop and time out from IRC, while the process itself is left running.

Stack:

ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-2' coro=<BasicClient.handle_forever() done, defined at /home/fuelrats/.local/lib/python3.8/site-packages/pydle/client.py:363> exception=AttributeError("'bool' object has no attribute 'replace'")>
Traceback (most recent call last):
File "/home/fuelrats/.local/lib/python3.8/site-packages/pydle/client.py", line 382, in handle_forever
await self.on_data(data)
File "/home/fuelrats/.local/lib/python3.8/site-packages/pydle/client.py", line 391, in on_data
message = self._parse_message()
File "/home/fuelrats/.local/lib/python3.8/site-packages/pydle/features/ircv3/tags.py", line 121, in _parse_message
return TaggedMessage.parse(message + sep, encoding=self.encoding)
File "/home/fuelrats/.local/lib/python3.8/site-packages/pydle/features/ircv3/tags.py", line 70, in parse
value = value.replace(escape, replacement)
AttributeError: 'bool' object has no attribute 'replace'

Further information: I've had a quick peek around, and the problem stems from the handling of values in tags. Pydle sets value to True if it doesn't exist, and this should work. However, later on an isinstance(value, str) apparently passes as true, but the value is actually a Boolean. As you cannot run .replace on a boolean, this causes the AttributeError. This would also cause an exception a few lines later in the regexp match attempt, as pattern.finditer() cannot run on a non-string/bytes object.

This can be resolved by adding exception handling to the regexp matching and replace attempt. However, a better fix may be correctly handling passed exceptions from the asyncio future in handle_forever().

duplicate of #148.

Will be fixed in release later today.