Skip to content

Commit

Permalink
Abstract methods should raise NotImplementedError, not return None
Browse files Browse the repository at this point in the history
getpeername() and getsockname() are part of the abstract API but weren't
defined.
  • Loading branch information
rthalley committed Jan 31, 2021
1 parent 3ee950f commit 5f45d60
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions dns/_asyncbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ class Socket: # pragma: no cover
async def close(self):
pass

async def getpeername(self):
raise NotImplementedError

async def getsockname(self):
raise NotImplementedError

async def __aenter__(self):
return self

Expand All @@ -36,18 +42,18 @@ async def __aexit__(self, exc_type, exc_value, traceback):

class DatagramSocket(Socket): # pragma: no cover
async def sendto(self, what, destination, timeout):
pass
raise NotImplementedError

async def recvfrom(self, size, timeout):
pass
raise NotImplementedError


class StreamSocket(Socket): # pragma: no cover
async def sendall(self, what, destination, timeout):
pass
raise NotImplementedError

async def recv(self, size, timeout):
pass
raise NotImplementedError


class Backend: # pragma: no cover
Expand Down

0 comments on commit 5f45d60

Please sign in to comment.