Merge pull request #18 from WGH-/master

use self.payload[:self.payload_len] for getting python string
This commit is contained in:
Matt Fox 2016-10-27 21:05:18 -07:00 committed by GitHub
commit adb254540b
2 changed files with 385 additions and 426 deletions

File diff suppressed because it is too large Load Diff

View File

@ -100,12 +100,7 @@ cdef class Packet:
def get_payload(self):
"""Return payload as Python string."""
cdef object py_string
if cpython.version.PY_MAJOR_VERSION >= 3:
py_string = PyBytes_FromStringAndSize(
self.payload, self.payload_len)
else:
py_string = PyString_FromStringAndSize(
self.payload, self.payload_len)
py_string = self.payload[:self.payload_len]
return py_string
cpdef Py_ssize_t get_payload_len(self):