diff options
| author | INADA Naoki <methane@users.noreply.github.com> | 2018-11-14 16:35:37 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-14 16:35:37 +0900 |
| commit | d782464c9150e448ab3a8d81197ff335e1ac2c2b (patch) | |
| tree | d008991560c7ca596e11e4e760a3e613fe252bc4 /msgpack/_packer.pyx | |
| parent | 2b5f59166beeccde0ee230c8673cf50932c8daba (diff) | |
| download | msgpack-python-d782464c9150e448ab3a8d81197ff335e1ac2c2b.tar.gz | |
Refactor Cython code (#328)
_msgpack -> _cmsgpack
Diffstat (limited to 'msgpack/_packer.pyx')
| -rw-r--r-- | msgpack/_packer.pyx | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/msgpack/_packer.pyx b/msgpack/_packer.pyx index 2643f85..3be593f 100644 --- a/msgpack/_packer.pyx +++ b/msgpack/_packer.pyx @@ -1,9 +1,7 @@ # coding: utf-8 -#cython: embedsignature=True, c_string_encoding=ascii from cpython cimport * -from cpython.version cimport PY_MAJOR_VERSION -from cpython.exc cimport PyErr_WarnEx +from cpython.bytearray cimport PyByteArray_Check, PyByteArray_CheckExact from msgpack import ExtType @@ -11,8 +9,6 @@ from msgpack import ExtType cdef extern from "Python.h": int PyMemoryView_Check(object obj) - int PyByteArray_Check(object obj) - int PyByteArray_CheckExact(object obj) char* PyUnicode_AsUTF8AndSize(object obj, Py_ssize_t *l) except NULL @@ -204,7 +200,7 @@ cdef class Packer(object): elif PyBytesLike_CheckExact(o) if strict_types else PyBytesLike_Check(o): L = len(o) if L > ITEM_LIMIT: - raise ValueError("%s is too large" % type(o).__name__) + PyErr_Format(ValueError, b"%.200s object is too large", Py_TYPE(o).tp_name) rawval = o ret = msgpack_pack_bin(&self.pk, L) if ret == 0: @@ -280,7 +276,7 @@ cdef class Packer(object): default_used = 1 continue else: - raise TypeError("can't serialize %r" % (o,)) + PyErr_Format(TypeError, b"can not serialize '%.200s' object", Py_TYPE(o).tp_name) return ret cpdef pack(self, object obj): |
