def to_bytes(self):
# TODO: This is a WORKAROUND!
# Before Python 2.7.7, struct.pack() only accepts native str.
# Uses of unicode will cause TypeError: Struct() argument 1 must be string, not unicode.
# This have been fixed by the Python community:
# https://hg.python.org/cpython/raw-file/f89216059edf/Misc/NEWS
return struct.pack(text_to_native_str(self.FORMAT), self.version, self.flag, self.length,
self.payload_type, self.reserved, self.seq, self.timestamp)
评论列表
文章目录