From: Brian Wellington Date: Fri, 23 Aug 2024 20:31:57 +0000 (-0700) Subject: Create EOFError exceptions with text EOF. (#1124) X-Git-Tag: v2.7.0rc1~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c97da58d0bc125eba8cbab3e7a85ddbfa71611d2;p=thirdparty%2Fdnspython.git Create EOFError exceptions with text EOF. (#1124) Previously, EOFErrors were being created with no text, leading to bad looking error messages. --- diff --git a/dns/_asyncio_backend.py b/dns/_asyncio_backend.py index de18c401..0c5e3bf8 100644 --- a/dns/_asyncio_backend.py +++ b/dns/_asyncio_backend.py @@ -42,7 +42,7 @@ class _DatagramProtocol: if exc is None: # EOF we triggered. Is there a better way to do this? try: - raise EOFError + raise EOFError('EOF') except EOFError as e: self.recvfrom.set_exception(e) else: diff --git a/dns/asyncquery.py b/dns/asyncquery.py index 622c9d52..05163fa9 100644 --- a/dns/asyncquery.py +++ b/dns/asyncquery.py @@ -342,7 +342,7 @@ async def _read_exactly(sock, count, expiration): while count > 0: n = await sock.recv(count, _timeout(expiration)) if n == b"": - raise EOFError + raise EOFError('EOF') count = count - len(n) s = s + n return s diff --git a/dns/query.py b/dns/query.py index 8e21ed2f..4af4eb23 100644 --- a/dns/query.py +++ b/dns/query.py @@ -976,7 +976,7 @@ def _net_read(sock, count, expiration): try: n = sock.recv(count) if n == b"": - raise EOFError + raise EOFError('EOF') count -= len(n) s += n except (BlockingIOError, ssl.SSLWantReadError):