From c97da58d0bc125eba8cbab3e7a85ddbfa71611d2 Mon Sep 17 00:00:00 2001 From: Brian Wellington Date: Fri, 23 Aug 2024 13:31:57 -0700 Subject: [PATCH] Create EOFError exceptions with text EOF. (#1124) Previously, EOFErrors were being created with no text, leading to bad looking error messages. --- dns/_asyncio_backend.py | 2 +- dns/asyncquery.py | 2 +- dns/query.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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): -- 2.47.3