@@ -31,7 +31,6 @@ cdef extern from "unpack.h":
3131 PyObject* object_hook
3232 PyObject* list_hook
3333 PyObject* ext_hook
34- char * encoding
3534 char * unicode_errors
3635 Py_ssize_t max_str_len
3736 Py_ssize_t max_bin_len
@@ -58,7 +57,7 @@ cdef inline init_ctx(unpack_context *ctx,
5857 object object_hook, object object_pairs_hook,
5958 object list_hook, object ext_hook,
6059 bint use_list, bint raw, bint strict_map_key,
61- const char * encoding, const char * unicode_errors,
60+ const char * unicode_errors,
6261 Py_ssize_t max_str_len, Py_ssize_t max_bin_len,
6362 Py_ssize_t max_array_len, Py_ssize_t max_map_len,
6463 Py_ssize_t max_ext_len):
@@ -99,7 +98,6 @@ cdef inline init_ctx(unpack_context *ctx,
9998 raise TypeError (" ext_hook must be a callable." )
10099 ctx.user.ext_hook = < PyObject* > ext_hook
101100
102- ctx.user.encoding = encoding
103101 ctx.user.unicode_errors = unicode_errors
104102
105103def default_read_extended_type (typecode , data ):
@@ -141,9 +139,9 @@ cdef inline int get_data_from_buffer(object obj,
141139 1 )
142140 return 1
143141
144- def unpackb (object packed , object object_hook = None , object list_hook = None ,
142+ def unpackb (object packed , *, object object_hook = None , object list_hook = None ,
145143 bint use_list = True , bint raw = True , bint strict_map_key = False ,
146- encoding = None , unicode_errors = None ,
144+ unicode_errors = None ,
147145 object_pairs_hook = None , ext_hook = ExtType,
148146 Py_ssize_t max_str_len = - 1 ,
149147 Py_ssize_t max_bin_len = - 1 ,
@@ -170,14 +168,9 @@ def unpackb(object packed, object object_hook=None, object list_hook=None,
170168 cdef Py_buffer view
171169 cdef char * buf = NULL
172170 cdef Py_ssize_t buf_len
173- cdef const char * cenc = NULL
174171 cdef const char * cerr = NULL
175172 cdef int new_protocol = 0
176173
177- if encoding is not None :
178- PyErr_WarnEx(DeprecationWarning , " encoding is deprecated, Use raw=False instead." , 1 )
179- cenc = encoding
180-
181174 if unicode_errors is not None :
182175 cerr = unicode_errors
183176
@@ -196,7 +189,7 @@ def unpackb(object packed, object object_hook=None, object list_hook=None,
196189
197190 try :
198191 init_ctx(& ctx, object_hook, object_pairs_hook, list_hook, ext_hook,
199- use_list, raw, strict_map_key, cenc, cerr,
192+ use_list, raw, strict_map_key, cerr,
200193 max_str_len, max_bin_len, max_array_len, max_map_len, max_ext_len)
201194 ret = unpack_construct(& ctx, buf, buf_len, & off)
202195 finally :
@@ -250,8 +243,6 @@ cdef class Unpacker(object):
250243 near future. So you must specify it explicitly for keeping backward
251244 compatibility.
252245
253- *encoding* option which is deprecated overrides this option.
254-
255246 :param bool strict_map_key:
256247 If true, only str or bytes are accepted for map (dict) keys.
257248 It's False by default for backward-compatibility.
@@ -290,11 +281,6 @@ cdef class Unpacker(object):
290281 Deprecated, use *max_buffer_size* instead.
291282 Limits max size of ext type. (default: max_buffer_size or 1024*1024)
292283
293- :param str encoding:
294- Deprecated, use ``raw=False`` instead.
295- Encoding used for decoding msgpack raw.
296- If it is None (default), msgpack raw is deserialized to Python bytes.
297-
298284 :param str unicode_errors:
299285 Error handler used for decoding str type. (default: `'strict'`)
300286
@@ -330,7 +316,7 @@ cdef class Unpacker(object):
330316 cdef Py_ssize_t read_size
331317 # To maintain refcnt.
332318 cdef object object_hook, object_pairs_hook, list_hook, ext_hook
333- cdef object encoding, unicode_errors
319+ cdef object unicode_errors
334320 cdef Py_ssize_t max_buffer_size
335321 cdef uint64_t stream_offset
336322
@@ -341,17 +327,16 @@ cdef class Unpacker(object):
341327 PyMem_Free(self .buf)
342328 self .buf = NULL
343329
344- def __init__ (self , file_like = None , Py_ssize_t read_size = 0 ,
330+ def __init__ (self , file_like = None , *, Py_ssize_t read_size = 0 ,
345331 bint use_list = True , bint raw = True , bint strict_map_key = False ,
346332 object object_hook = None , object object_pairs_hook = None , object list_hook = None ,
347- encoding = None , unicode_errors = None , Py_ssize_t max_buffer_size = 0 ,
333+ unicode_errors = None , Py_ssize_t max_buffer_size = 0 ,
348334 object ext_hook = ExtType,
349335 Py_ssize_t max_str_len = - 1 ,
350336 Py_ssize_t max_bin_len = - 1 ,
351337 Py_ssize_t max_array_len = - 1 ,
352338 Py_ssize_t max_map_len = - 1 ,
353339 Py_ssize_t max_ext_len = - 1 ):
354- cdef const char * cenc= NULL ,
355340 cdef const char * cerr= NULL
356341
357342 self .object_hook = object_hook
@@ -392,17 +377,12 @@ cdef class Unpacker(object):
392377 self .buf_tail = 0
393378 self .stream_offset = 0
394379
395- if encoding is not None :
396- PyErr_WarnEx(DeprecationWarning , " encoding is deprecated, Use raw=False instead." , 1 )
397- self .encoding = encoding
398- cenc = encoding
399-
400380 if unicode_errors is not None :
401381 self .unicode_errors = unicode_errors
402382 cerr = unicode_errors
403383
404384 init_ctx(& self .ctx, object_hook, object_pairs_hook, list_hook,
405- ext_hook, use_list, raw, strict_map_key, cenc, cerr,
385+ ext_hook, use_list, raw, strict_map_key, cerr,
406386 max_str_len, max_bin_len, max_array_len,
407387 max_map_len, max_ext_len)
408388
0 commit comments