summaryrefslogtreecommitdiff
path: root/msgpack/_packer.pyx
diff options
context:
space:
mode:
authorInada Naoki <songofacandy@gmail.com>2019-12-03 18:54:01 +0900
committerGitHub <noreply@github.com>2019-12-03 18:54:01 +0900
commite1ed0044bf31dc0d6ef951f6298de4f420170968 (patch)
treee12172aafa58a61cf555ed20a5d5ac7f9aa22dfc /msgpack/_packer.pyx
parentcc3a8665d6210e933bcfb9120bd0ceb15224f03e (diff)
downloadmsgpack-python-e1ed0044bf31dc0d6ef951f6298de4f420170968.tar.gz
Remove encoding/unicode_errors options from Packer (#378)
Diffstat (limited to 'msgpack/_packer.pyx')
-rw-r--r--msgpack/_packer.pyx46
1 files changed, 7 insertions, 39 deletions
diff --git a/msgpack/_packer.pyx b/msgpack/_packer.pyx
index e620914..2e698e1 100644
--- a/msgpack/_packer.pyx
+++ b/msgpack/_packer.pyx
@@ -89,19 +89,9 @@ cdef class Packer(object):
Additionally tuples will not be serialized as lists.
This is useful when trying to implement accurate serialization
for python types.
-
- :param str unicode_errors:
- Error handler for encoding unicode. (default: 'strict')
-
- :param str encoding:
- (deprecated) Convert unicode to bytes with this encoding. (default: 'utf-8')
"""
cdef msgpack_packer pk
cdef object _default
- cdef object _bencoding
- cdef object _berrors
- cdef const char *encoding
- cdef const char *unicode_errors
cdef bint strict_types
cdef bool use_float
cdef bint autoreset
@@ -114,11 +104,11 @@ cdef class Packer(object):
self.pk.buf_size = buf_size
self.pk.length = 0
- def __init__(self, default=None, encoding=None, unicode_errors=None,
- bint use_single_float=False, bint autoreset=True, bint use_bin_type=False,
+ def __init__(self, default=None,
+ bint use_single_float=False,
+ bint autoreset=True,
+ bint use_bin_type=False,
bint strict_types=False):
- if encoding is not None:
- PyErr_WarnEx(DeprecationWarning, "encoding is deprecated.", 1)
self.use_float = use_single_float
self.strict_types = strict_types
self.autoreset = autoreset
@@ -128,18 +118,6 @@ cdef class Packer(object):
raise TypeError("default must be a callable.")
self._default = default
- self._bencoding = encoding
- if encoding is None:
- self.encoding = 'utf-8'
- else:
- self.encoding = self._bencoding
-
- self._berrors = unicode_errors
- if unicode_errors is None:
- self.unicode_errors = NULL
- else:
- self.unicode_errors = self._berrors
-
def __dealloc__(self):
PyMem_Free(self.pk.buf)
self.pk.buf = NULL
@@ -205,19 +183,9 @@ cdef class Packer(object):
if ret == 0:
ret = msgpack_pack_raw_body(&self.pk, rawval, L)
elif PyUnicode_CheckExact(o) if strict_types else PyUnicode_Check(o):
- if self.encoding == NULL and self.unicode_errors == NULL:
- ret = msgpack_pack_unicode(&self.pk, o, ITEM_LIMIT);
- if ret == -2:
- raise ValueError("unicode string is too large")
- else:
- o = PyUnicode_AsEncodedString(o, self.encoding, self.unicode_errors)
- L = Py_SIZE(o)
- if L > ITEM_LIMIT:
- raise ValueError("unicode string is too large")
- ret = msgpack_pack_raw(&self.pk, L)
- if ret == 0:
- rawval = o
- ret = msgpack_pack_raw_body(&self.pk, rawval, L)
+ ret = msgpack_pack_unicode(&self.pk, o, ITEM_LIMIT);
+ if ret == -2:
+ raise ValueError("unicode string is too large")
elif PyDict_CheckExact(o):
d = <dict>o
L = len(d)