Skip to content

Commit

Permalink
Fix regression with python2, now that content can be "unicode",
Browse files Browse the repository at this point in the history
not "str".

Issue:	#30
  • Loading branch information
sobomax committed Oct 26, 2020
1 parent 1688c9a commit f1c375b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sippy/MsgBody.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@

b_types = {'application/sdp':SdpBody}

try:
# Python < 3
str_types = (str, unicode)
except NameError:
str_types = (str,)

class MsgBody(object):
content = None
mtype = None
Expand All @@ -40,7 +46,7 @@ def __init__(self, content = None, mtype = 'application/sdp', cself = None):
self.mtype = mtype
self.content = content
else:
if type(cself.content) == str:
if type(cself.content) in str_types:
self.content = cself.content
else:
self.content = cself.content.getCopy()
Expand All @@ -57,7 +63,7 @@ def __str__(self):
return str(self.content)

def localStr(self, local_addr = None, local_port = None):
if type(self.content) == str:
if type(self.content) in str_types:
return self.content
return self.content.localStr(local_addr, local_port)

Expand Down

0 comments on commit f1c375b

Please # to comment.