@@ -89,19 +89,9 @@ cdef class Packer(object):
8989 Additionally tuples will not be serialized as lists.
9090 This is useful when trying to implement accurate serialization
9191 for python types.
92-
93- :param str unicode_errors:
94- Error handler for encoding unicode. (default: 'strict')
95-
96- :param str encoding:
97- (deprecated) Convert unicode to bytes with this encoding. (default: 'utf-8')
9892 """
9993 cdef msgpack_packer pk
10094 cdef object _default
101- cdef object _bencoding
102- cdef object _berrors
103- cdef const char * encoding
104- cdef const char * unicode_errors
10595 cdef bint strict_types
10696 cdef bool use_float
10797 cdef bint autoreset
@@ -114,11 +104,11 @@ cdef class Packer(object):
114104 self .pk.buf_size = buf_size
115105 self .pk.length = 0
116106
117- def __init__ (self , default = None , encoding = None , unicode_errors = None ,
118- bint use_single_float = False , bint autoreset = True , bint use_bin_type = False ,
107+ def __init__ (self , default = None ,
108+ bint use_single_float = False ,
109+ bint autoreset = True ,
110+ bint use_bin_type = False ,
119111 bint strict_types = False ):
120- if encoding is not None :
121- PyErr_WarnEx(DeprecationWarning , " encoding is deprecated." , 1 )
122112 self .use_float = use_single_float
123113 self .strict_types = strict_types
124114 self .autoreset = autoreset
@@ -128,18 +118,6 @@ cdef class Packer(object):
128118 raise TypeError (" default must be a callable." )
129119 self ._default = default
130120
131- self ._bencoding = encoding
132- if encoding is None :
133- self .encoding = ' utf-8'
134- else :
135- self .encoding = self ._bencoding
136-
137- self ._berrors = unicode_errors
138- if unicode_errors is None :
139- self .unicode_errors = NULL
140- else :
141- self .unicode_errors = self ._berrors
142-
143121 def __dealloc__ (self ):
144122 PyMem_Free(self .pk.buf)
145123 self .pk.buf = NULL
@@ -205,19 +183,9 @@ cdef class Packer(object):
205183 if ret == 0 :
206184 ret = msgpack_pack_raw_body(& self .pk, rawval, L)
207185 elif PyUnicode_CheckExact(o) if strict_types else PyUnicode_Check(o):
208- if self .encoding == NULL and self .unicode_errors == NULL :
209- ret = msgpack_pack_unicode(& self .pk, o, ITEM_LIMIT);
210- if ret == - 2 :
211- raise ValueError (" unicode string is too large" )
212- else :
213- o = PyUnicode_AsEncodedString(o, self .encoding, self .unicode_errors)
214- L = Py_SIZE(o)
215- if L > ITEM_LIMIT:
216- raise ValueError (" unicode string is too large" )
217- ret = msgpack_pack_raw(& self .pk, L)
218- if ret == 0 :
219- rawval = o
220- ret = msgpack_pack_raw_body(& self .pk, rawval, L)
186+ ret = msgpack_pack_unicode(& self .pk, o, ITEM_LIMIT);
187+ if ret == - 2 :
188+ raise ValueError (" unicode string is too large" )
221189 elif PyDict_CheckExact(o):
222190 d = < dict > o
223191 L = len (d)
0 commit comments