Fix attempt to use non-existent name

This theoretically also changes the meaning of the code from running
the callback always, to only running the callback when there wasn't an
error, which is what I'm assuming was meant, but in pratical terms,
attempting to use `data` in the case of an error would have raised a
`NameError` anyway.

`else` on a try block will only run if nothing was raised.
This commit is contained in:
rakiru 2018-01-11 20:25:39 +00:00
parent d29da0abbc
commit 895a5c91a5
1 changed files with 2 additions and 1 deletions

View File

@ -21,7 +21,8 @@ class Connection:
data = receive(self.sock)
except Exception as err:
onError(err)
callback(data)
else:
callback(data)
def send(self, message):
send(self.sock, bytes(message, 'utf-8'))