Commit 5d499c8d authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Catch and close on unicode errors in stream

parent 47a84d2e
Loading
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -253,7 +253,11 @@ class BaseClient:
		assert self.sock is not None, \
			"RuntimeError should have been raised by a public method if self.sock is None"

		try:
			msg = (await self.sock.receive()).decode().strip()
		except (UnicodeDecodeError, anyio.EndOfStream):
			await self.sock.aclose()
			raise anyio.ClosedResourceError

		self.logger.debug("Received: %s", repr(msg))
		match = self.event_regex.match(msg)