From a27c6f3ffed9754b17b0b087ab59c8c38497c897 Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Tue, 26 Jan 2016 17:44:11 +0000 Subject: [PATCH] made sendall accept APRSPacket instances --- aprslib/inet.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/aprslib/inet.py b/aprslib/inet.py index 0fa8cb0..cafd510 100644 --- a/aprslib/inet.py +++ b/aprslib/inet.py @@ -25,6 +25,7 @@ import logging from aprslib import __version__, string_type, is_py3 from aprslib.parsing import parse +from aprslib.packets.base import APRSPacket from aprslib.exceptions import ( GenericError, ConnectionDrop, @@ -136,8 +137,10 @@ class IS(object): """ Send a line, or multiple lines sperapted by '\\r\\n' """ - if not isinstance(line, string_type): - raise TypeError("Expected line to be str, got %s", type(line)) + if isinstance(line, APRSPacket): + line = str(line) + elif not isinstance(line, string_type): + raise TypeError("Expected line to be str or APRSPacket, got %s", type(line)) if not self._connected: raise ConnectionError("not connected")