@@ -31,7 +31,6 @@ cdef extern from "unpack.h":
31
31
PyObject* object_hook
32
32
PyObject* list_hook
33
33
PyObject* ext_hook
34
- char * encoding
35
34
char * unicode_errors
36
35
Py_ssize_t max_str_len
37
36
Py_ssize_t max_bin_len
@@ -58,7 +57,7 @@ cdef inline init_ctx(unpack_context *ctx,
58
57
object object_hook, object object_pairs_hook,
59
58
object list_hook, object ext_hook,
60
59
bint use_list, bint raw, bint strict_map_key,
61
- const char * encoding, const char * unicode_errors,
60
+ const char * unicode_errors,
62
61
Py_ssize_t max_str_len, Py_ssize_t max_bin_len,
63
62
Py_ssize_t max_array_len, Py_ssize_t max_map_len,
64
63
Py_ssize_t max_ext_len):
@@ -99,7 +98,6 @@ cdef inline init_ctx(unpack_context *ctx,
99
98
raise TypeError (" ext_hook must be a callable." )
100
99
ctx.user.ext_hook = < PyObject* > ext_hook
101
100
102
- ctx.user.encoding = encoding
103
101
ctx.user.unicode_errors = unicode_errors
104
102
105
103
def default_read_extended_type (typecode , data ):
@@ -141,9 +139,9 @@ cdef inline int get_data_from_buffer(object obj,
141
139
1 )
142
140
return 1
143
141
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 ,
145
143
bint use_list = True , bint raw = True , bint strict_map_key = False ,
146
- encoding = None , unicode_errors = None ,
144
+ unicode_errors = None ,
147
145
object_pairs_hook = None , ext_hook = ExtType,
148
146
Py_ssize_t max_str_len = - 1 ,
149
147
Py_ssize_t max_bin_len = - 1 ,
@@ -170,14 +168,9 @@ def unpackb(object packed, object object_hook=None, object list_hook=None,
170
168
cdef Py_buffer view
171
169
cdef char * buf = NULL
172
170
cdef Py_ssize_t buf_len
173
- cdef const char * cenc = NULL
174
171
cdef const char * cerr = NULL
175
172
cdef int new_protocol = 0
176
173
177
- if encoding is not None :
178
- PyErr_WarnEx(DeprecationWarning , " encoding is deprecated, Use raw=False instead." , 1 )
179
- cenc = encoding
180
-
181
174
if unicode_errors is not None :
182
175
cerr = unicode_errors
183
176
@@ -196,7 +189,7 @@ def unpackb(object packed, object object_hook=None, object list_hook=None,
196
189
197
190
try :
198
191
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,
200
193
max_str_len, max_bin_len, max_array_len, max_map_len, max_ext_len)
201
194
ret = unpack_construct(& ctx, buf, buf_len, & off)
202
195
finally :
@@ -250,8 +243,6 @@ cdef class Unpacker(object):
250
243
near future. So you must specify it explicitly for keeping backward
251
244
compatibility.
252
245
253
- *encoding* option which is deprecated overrides this option.
254
-
255
246
:param bool strict_map_key:
256
247
If true, only str or bytes are accepted for map (dict) keys.
257
248
It's False by default for backward-compatibility.
@@ -290,11 +281,6 @@ cdef class Unpacker(object):
290
281
Deprecated, use *max_buffer_size* instead.
291
282
Limits max size of ext type. (default: max_buffer_size or 1024*1024)
292
283
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
-
298
284
:param str unicode_errors:
299
285
Error handler used for decoding str type. (default: `'strict'`)
300
286
@@ -330,7 +316,7 @@ cdef class Unpacker(object):
330
316
cdef Py_ssize_t read_size
331
317
# To maintain refcnt.
332
318
cdef object object_hook, object_pairs_hook, list_hook, ext_hook
333
- cdef object encoding, unicode_errors
319
+ cdef object unicode_errors
334
320
cdef Py_ssize_t max_buffer_size
335
321
cdef uint64_t stream_offset
336
322
@@ -341,17 +327,16 @@ cdef class Unpacker(object):
341
327
PyMem_Free(self .buf)
342
328
self .buf = NULL
343
329
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 ,
345
331
bint use_list = True , bint raw = True , bint strict_map_key = False ,
346
332
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 ,
348
334
object ext_hook = ExtType,
349
335
Py_ssize_t max_str_len = - 1 ,
350
336
Py_ssize_t max_bin_len = - 1 ,
351
337
Py_ssize_t max_array_len = - 1 ,
352
338
Py_ssize_t max_map_len = - 1 ,
353
339
Py_ssize_t max_ext_len = - 1 ):
354
- cdef const char * cenc= NULL ,
355
340
cdef const char * cerr= NULL
356
341
357
342
self .object_hook = object_hook
@@ -392,17 +377,12 @@ cdef class Unpacker(object):
392
377
self .buf_tail = 0
393
378
self .stream_offset = 0
394
379
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
-
400
380
if unicode_errors is not None :
401
381
self .unicode_errors = unicode_errors
402
382
cerr = unicode_errors
403
383
404
384
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,
406
386
max_str_len, max_bin_len, max_array_len,
407
387
max_map_len, max_ext_len)
408
388
0 commit comments