Skip to content

Commit 9fdb837

Browse files
authored
Undeprecate unicode_errors (#278)
1 parent 618b2cb commit 9fdb837

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

msgpack/_packer.pyx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,11 @@ cdef class Packer(object):
8989
This is useful when trying to implement accurate serialization
9090
for python types.
9191
92+
:param str unicode_errors:
93+
Error handler for encoding unicode. (default: 'strict')
94+
9295
:param str encoding:
9396
(deprecated) Convert unicode to bytes with this encoding. (default: 'utf-8')
94-
:param str unicode_errors:
95-
(deprecated) Error handler for encoding unicode. (default: 'strict')
9697
"""
9798
cdef msgpack_packer pk
9899
cdef object _default
@@ -117,8 +118,6 @@ cdef class Packer(object):
117118
bint strict_types=False):
118119
if encoding is not None:
119120
PyErr_WarnEx(PendingDeprecationWarning, "encoding is deprecated.", 1)
120-
if unicode_errors is not None:
121-
PyErr_WarnEx(PendingDeprecationWarning, "unicode_errors is deprecated.", 1)
122121
self.use_float = use_single_float
123122
self.strict_types = strict_types
124123
self.autoreset = autoreset

msgpack/_unpacker.pyx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ cdef inline int get_data_from_buffer(object obj,
159159

160160
def unpackb(object packed, object object_hook=None, object list_hook=None,
161161
bint use_list=True, bint raw=True,
162-
encoding=None, unicode_errors="strict",
162+
encoding=None, unicode_errors=None,
163163
object_pairs_hook=None, ext_hook=ExtType,
164164
Py_ssize_t max_str_len=2147483647, # 2**32-1
165165
Py_ssize_t max_bin_len=2147483647,
@@ -193,7 +193,6 @@ def unpackb(object packed, object object_hook=None, object list_hook=None,
193193
cenc = PyBytes_AsString(encoding)
194194

195195
if unicode_errors is not None:
196-
PyErr_WarnEx(PendingDeprecationWarning, "unicode_errors is deprecated", 1)
197196
if isinstance(unicode_errors, unicode):
198197
unicode_errors = unicode_errors.encode('ascii')
199198
elif not isinstance(unicode_errors, bytes):
@@ -304,8 +303,7 @@ cdef class Unpacker(object):
304303
If it is None (default), msgpack raw is deserialized to Python bytes.
305304
306305
:param str unicode_errors:
307-
Deprecated. Used for decoding msgpack raw with *encoding*.
308-
(default: `'strict'`)
306+
Error handler used for decoding str type. (default: `'strict'`)
309307
310308
311309
Example of streaming deserialize from file-like object::
@@ -347,7 +345,7 @@ cdef class Unpacker(object):
347345
def __init__(self, file_like=None, Py_ssize_t read_size=0,
348346
bint use_list=True, bint raw=True,
349347
object object_hook=None, object object_pairs_hook=None, object list_hook=None,
350-
encoding=None, unicode_errors='strict', int max_buffer_size=0,
348+
encoding=None, unicode_errors=None, int max_buffer_size=0,
351349
object ext_hook=ExtType,
352350
Py_ssize_t max_str_len=2147483647, # 2**32-1
353351
Py_ssize_t max_bin_len=2147483647,
@@ -394,7 +392,6 @@ cdef class Unpacker(object):
394392
cenc = PyBytes_AsString(self.encoding)
395393

396394
if unicode_errors is not None:
397-
PyErr_WarnEx(PendingDeprecationWarning, "unicode_errors is deprecated", 1)
398395
if isinstance(unicode_errors, unicode):
399396
self.unicode_errors = unicode_errors.encode('ascii')
400397
elif isinstance(unicode_errors, bytes):

msgpack/unpack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static inline int unpack_callback_raw(unpack_user* u, const char* b, const char*
232232
} else if (u->raw) {
233233
py = PyBytes_FromStringAndSize(p, l);
234234
} else {
235-
py = PyUnicode_DecodeUTF8(p, l, NULL);
235+
py = PyUnicode_DecodeUTF8(p, l, u->unicode_errors);
236236
}
237237
if (!py)
238238
return -1;

0 commit comments

Comments
 (0)