mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-11-10 06:21:03 +00:00
Remove encoding/unicode_errors options from Packer (#378)
This commit is contained in:
parent
cc3a8665d6
commit
e1ed0044bf
3 changed files with 9 additions and 93 deletions
|
|
@ -752,32 +752,14 @@ 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 encoding:
|
||||
(deprecated) Convert unicode to bytes with this encoding. (default: 'utf-8')
|
||||
|
||||
:param str unicode_errors:
|
||||
Error handler for encoding unicode. (default: 'strict')
|
||||
"""
|
||||
def __init__(self, default=None, encoding=None, unicode_errors=None,
|
||||
def __init__(self, default=None,
|
||||
use_single_float=False, autoreset=True, use_bin_type=False,
|
||||
strict_types=False):
|
||||
if encoding is None:
|
||||
encoding = 'utf_8'
|
||||
else:
|
||||
warnings.warn(
|
||||
"encoding is deprecated, Use raw=False instead.",
|
||||
DeprecationWarning, stacklevel=2)
|
||||
|
||||
if unicode_errors is None:
|
||||
unicode_errors = 'strict'
|
||||
|
||||
self._strict_types = strict_types
|
||||
self._use_float = use_single_float
|
||||
self._autoreset = autoreset
|
||||
self._use_bin_type = use_bin_type
|
||||
self._encoding = encoding
|
||||
self._unicode_errors = unicode_errors
|
||||
self._buffer = StringIO()
|
||||
if default is not None:
|
||||
if not callable(default):
|
||||
|
|
@ -834,11 +816,7 @@ class Packer(object):
|
|||
self._pack_bin_header(n)
|
||||
return self._buffer.write(obj)
|
||||
if check(obj, unicode):
|
||||
if self._encoding is None:
|
||||
raise TypeError(
|
||||
"Can't encode unicode string: "
|
||||
"no encoding is specified")
|
||||
obj = obj.encode(self._encoding, self._unicode_errors)
|
||||
obj = obj.encode("utf-8")
|
||||
n = len(obj)
|
||||
if n >= 2**32:
|
||||
raise ValueError("String is too large")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue