22# cython: embedsignature=True
33
44from cpython cimport *
5- from cpython.exc cimport PyErr_WarnEx
5+ # from cpython.exc cimport PyErr_WarnEx
66
77from msgpack.exceptions import PackValueError, PackOverflowError
88from msgpack import ExtType
@@ -65,27 +65,32 @@ cdef class Packer(object):
6565 :param callable default:
6666 Convert user type to builtin type that Packer supports.
6767 See also simplejson's document.
68- :param str encoding:
69- Convert unicode to bytes with this encoding. (default: 'utf-8')
70- :param str unicode_errors:
71- Error handler for encoding unicode. (default: 'strict')
68+
7269 :param bool use_single_float:
7370 Use single precision float type for float. (default: False)
71+
7472 :param bool autoreset:
7573 Reset buffer after each pack and return its content as `bytes`. (default: True).
7674 If set this to false, use `bytes()` to get content and `.reset()` to clear buffer.
75+
7776 :param bool use_bin_type:
7877 Use bin type introduced in msgpack spec 2.0 for bytes.
7978 It also enables str8 type for unicode.
8079 Current default value is false, but it will be changed to true
8180 in future version. You should specify it explicitly.
81+
8282 :param bool strict_types:
8383 If set to true, types will be checked to be exact. Derived classes
8484 from serializeable types will not be serialized and will be
8585 treated as unsupported type and forwarded to default.
8686 Additionally tuples will not be serialized as lists.
8787 This is useful when trying to implement accurate serialization
8888 for python types.
89+
90+ :param str encoding:
91+ (deprecated) Convert unicode to bytes with this encoding. (default: 'utf-8')
92+ :param str unicode_errors:
93+ (deprecated) Error handler for encoding unicode. (default: 'strict')
8994 """
9095 cdef msgpack_packer pk
9196 cdef object _default
@@ -106,17 +111,12 @@ cdef class Packer(object):
106111 self .pk.length = 0
107112
108113 def __init__ (self , default = None , encoding = ' utf-8' , unicode_errors = ' strict' ,
109- use_single_float = False , bint autoreset = 1 , use_bin_type = None ,
110- bint strict_types = 0 ):
111- if use_bin_type is None :
112- PyErr_WarnEx(
113- FutureWarning ,
114- " use_bin_type option is not specified. Default value of the option will be changed in future version." ,
115- 1 )
114+ bint use_single_float = False , bint autoreset = True , bint use_bin_type = False ,
115+ bint strict_types = False ):
116116 self .use_float = use_single_float
117117 self .strict_types = strict_types
118118 self .autoreset = autoreset
119- self .pk.use_bin_type = < bint > use_bin_type
119+ self .pk.use_bin_type = use_bin_type
120120 if default is not None :
121121 if not PyCallable_Check(default):
122122 raise TypeError (" default must be a callable." )
0 commit comments