We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b3fd7b4 commit d0cb8c4Copy full SHA for d0cb8c4
1 file changed
sipsimple/streams/msrp/chat.py
@@ -786,11 +786,13 @@ def encode(self):
786
787
@classmethod
788
def decode(cls, content, content_type):
789
- if not isinstance(content, bytes):
790
- raise TypeError("content should be an instance of bytes")
+ if not isinstance(content, bytes) and not isinstance(content, str):
+ raise TypeError("content should be an instance of bytes or string")
791
type_helper = EmailParser().parsestr('Content-Type: {}'.format(content_type))
792
content_type = type_helper.get_content_type()
793
charset = type_helper.get_content_charset()
794
+ if isinstance(content, str):
795
+ content = content.encode(charset if charset else "ascii", "replace")
796
return cls(content, content_type, charset)
797
798
0 commit comments