2
2
# cython: embedsignature=True
3
3
4
4
from cpython cimport *
5
- from cpython.exc cimport PyErr_WarnEx
5
+ # from cpython.exc cimport PyErr_WarnEx
6
6
7
7
from msgpack.exceptions import PackValueError, PackOverflowError
8
8
from msgpack import ExtType
@@ -65,27 +65,32 @@ cdef class Packer(object):
65
65
:param callable default:
66
66
Convert user type to builtin type that Packer supports.
67
67
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
+
72
69
:param bool use_single_float:
73
70
Use single precision float type for float. (default: False)
71
+
74
72
:param bool autoreset:
75
73
Reset buffer after each pack and return its content as `bytes`. (default: True).
76
74
If set this to false, use `bytes()` to get content and `.reset()` to clear buffer.
75
+
77
76
:param bool use_bin_type:
78
77
Use bin type introduced in msgpack spec 2.0 for bytes.
79
78
It also enables str8 type for unicode.
80
79
Current default value is false, but it will be changed to true
81
80
in future version. You should specify it explicitly.
81
+
82
82
:param bool strict_types:
83
83
If set to true, types will be checked to be exact. Derived classes
84
84
from serializeable types will not be serialized and will be
85
85
treated as unsupported type and forwarded to default.
86
86
Additionally tuples will not be serialized as lists.
87
87
This is useful when trying to implement accurate serialization
88
88
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')
89
94
"""
90
95
cdef msgpack_packer pk
91
96
cdef object _default
@@ -106,17 +111,12 @@ cdef class Packer(object):
106
111
self .pk.length = 0
107
112
108
113
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 ):
116
116
self .use_float = use_single_float
117
117
self .strict_types = strict_types
118
118
self .autoreset = autoreset
119
- self .pk.use_bin_type = < bint > use_bin_type
119
+ self .pk.use_bin_type = use_bin_type
120
120
if default is not None :
121
121
if not PyCallable_Check(default):
122
122
raise TypeError (" default must be a callable." )
0 commit comments