ormsgpack 1.8.0__tar.gz → 1.9.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ormsgpack might be problematic. Click here for more details.

Files changed (54) hide show
  1. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/CHANGELOG.md +14 -0
  2. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/Cargo.lock +35 -53
  3. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/Cargo.toml +6 -7
  4. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/PKG-INFO +6 -2
  5. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/README.md +5 -1
  6. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/pyproject.toml +7 -2
  7. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/python/ormsgpack/__init__.py +2 -0
  8. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/python/ormsgpack/__init__.pyi +1 -0
  9. ormsgpack-1.9.1/python/ormsgpack/_pyinstaller/__init__.py +7 -0
  10. ormsgpack-1.9.1/python/ormsgpack/_pyinstaller/hook-ormsgpack.py +7 -0
  11. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/deserialize/deserializer.rs +1 -1
  12. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/exc.rs +0 -1
  13. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/ext.rs +5 -5
  14. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/lib.rs +31 -36
  15. ormsgpack-1.9.1/src/msgpack/array.rs +21 -0
  16. ormsgpack-1.9.1/src/msgpack/bin.rs +24 -0
  17. ormsgpack-1.9.1/src/msgpack/bool.rs +13 -0
  18. ormsgpack-1.9.1/src/msgpack/ext.rs +35 -0
  19. ormsgpack-1.9.1/src/msgpack/float.rs +22 -0
  20. ormsgpack-1.9.1/src/msgpack/int.rs +50 -0
  21. ormsgpack-1.9.1/src/msgpack/map.rs +21 -0
  22. ormsgpack-1.9.1/src/msgpack/marker.rs +165 -0
  23. ormsgpack-1.9.1/src/msgpack/mod.rs +23 -0
  24. ormsgpack-1.9.1/src/msgpack/nil.rs +12 -0
  25. ormsgpack-1.9.1/src/msgpack/str.rs +26 -0
  26. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/opt.rs +6 -3
  27. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/serialize/dataclass.rs +0 -87
  28. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/serialize/mod.rs +1 -0
  29. ormsgpack-1.9.1/src/serialize/pydantic.rs +108 -0
  30. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/serialize/serializer.rs +41 -26
  31. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/typeref.rs +50 -112
  32. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/LICENSE-APACHE +0 -0
  33. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/LICENSE-MIT +0 -0
  34. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/build.rs +0 -0
  35. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/python/ormsgpack/py.typed +0 -0
  36. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/deserialize/cache.rs +0 -0
  37. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/deserialize/error.rs +0 -0
  38. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/deserialize/mod.rs +0 -0
  39. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/ffi.rs +0 -0
  40. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/serialize/bytes.rs +0 -0
  41. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/serialize/datetime.rs +0 -0
  42. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/serialize/datetimelike.rs +0 -0
  43. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/serialize/default.rs +0 -0
  44. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/serialize/dict.rs +0 -0
  45. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/serialize/ext.rs +0 -0
  46. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/serialize/int.rs +0 -0
  47. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/serialize/list.rs +0 -0
  48. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/serialize/numpy.rs +0 -0
  49. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/serialize/str.rs +0 -0
  50. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/serialize/tuple.rs +0 -0
  51. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/serialize/uuid.rs +0 -0
  52. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/serialize/writer.rs +0 -0
  53. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/unicode.rs +0 -0
  54. {ormsgpack-1.8.0 → ormsgpack-1.9.1}/src/util.rs +0 -0
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.9.1 28/03/2025
4
+
5
+ ### Changed
6
+
7
+ - Add musllinux wheels [#366](/../../issues/366)
8
+
9
+ ## 1.9.0 23/03/2025
10
+
11
+ ### Changed
12
+
13
+ - Add `packb` option `OPT_PASSTHROUGH_ENUM` to enable passthrough of Enum objects by [hinthornw](https://github.com/hinthornw) in [#361](/../../pull/361)
14
+ - Add PyInstaller hook [#354](/../../issues/354)
15
+ - Update dependencies
16
+
3
17
  ## 1.8.0 22/02/2025
4
18
 
5
19
  ### Fixed
@@ -40,9 +40,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
40
40
 
41
41
  [[package]]
42
42
  name = "chrono"
43
- version = "0.4.39"
43
+ version = "0.4.40"
44
44
  source = "registry+https://github.com/rust-lang/crates.io-index"
45
- checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825"
45
+ checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c"
46
46
  dependencies = [
47
47
  "num-traits",
48
48
  ]
@@ -55,9 +55,9 @@ checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929"
55
55
 
56
56
  [[package]]
57
57
  name = "half"
58
- version = "2.4.1"
58
+ version = "2.5.0"
59
59
  source = "registry+https://github.com/rust-lang/crates.io-index"
60
- checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888"
60
+ checksum = "7db2ff139bba50379da6aa0766b52fdcb62cb5b263009b09ed58ba604e14bbd1"
61
61
  dependencies = [
62
62
  "cfg-if",
63
63
  "crunchy",
@@ -65,15 +65,15 @@ dependencies = [
65
65
 
66
66
  [[package]]
67
67
  name = "itoa"
68
- version = "1.0.14"
68
+ version = "1.0.15"
69
69
  source = "registry+https://github.com/rust-lang/crates.io-index"
70
- checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
70
+ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
71
71
 
72
72
  [[package]]
73
73
  name = "libc"
74
- version = "0.2.169"
74
+ version = "0.2.171"
75
75
  source = "registry+https://github.com/rust-lang/crates.io-index"
76
- checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
76
+ checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
77
77
 
78
78
  [[package]]
79
79
  name = "memoffset"
@@ -95,13 +95,13 @@ dependencies = [
95
95
 
96
96
  [[package]]
97
97
  name = "once_cell"
98
- version = "1.20.3"
98
+ version = "1.21.1"
99
99
  source = "registry+https://github.com/rust-lang/crates.io-index"
100
- checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e"
100
+ checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc"
101
101
 
102
102
  [[package]]
103
103
  name = "ormsgpack"
104
- version = "1.8.0"
104
+ version = "1.9.1"
105
105
  dependencies = [
106
106
  "ahash",
107
107
  "bytecount",
@@ -112,39 +112,32 @@ dependencies = [
112
112
  "once_cell",
113
113
  "pyo3",
114
114
  "pyo3-build-config",
115
- "rmp",
116
115
  "serde",
117
116
  "serde_bytes",
118
117
  "simdutf8",
119
118
  "smallvec",
120
119
  ]
121
120
 
122
- [[package]]
123
- name = "paste"
124
- version = "1.0.15"
125
- source = "registry+https://github.com/rust-lang/crates.io-index"
126
- checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
127
-
128
121
  [[package]]
129
122
  name = "portable-atomic"
130
- version = "1.10.0"
123
+ version = "1.11.0"
131
124
  source = "registry+https://github.com/rust-lang/crates.io-index"
132
- checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6"
125
+ checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e"
133
126
 
134
127
  [[package]]
135
128
  name = "proc-macro2"
136
- version = "1.0.93"
129
+ version = "1.0.94"
137
130
  source = "registry+https://github.com/rust-lang/crates.io-index"
138
- checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
131
+ checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
139
132
  dependencies = [
140
133
  "unicode-ident",
141
134
  ]
142
135
 
143
136
  [[package]]
144
137
  name = "pyo3"
145
- version = "0.23.4"
138
+ version = "0.24.0"
146
139
  source = "registry+https://github.com/rust-lang/crates.io-index"
147
- checksum = "57fe09249128b3173d092de9523eaa75136bf7ba85e0d69eca241c7939c933cc"
140
+ checksum = "7f1c6c3591120564d64db2261bec5f910ae454f01def849b9c22835a84695e86"
148
141
  dependencies = [
149
142
  "cfg-if",
150
143
  "libc",
@@ -157,9 +150,9 @@ dependencies = [
157
150
 
158
151
  [[package]]
159
152
  name = "pyo3-build-config"
160
- version = "0.23.4"
153
+ version = "0.24.0"
161
154
  source = "registry+https://github.com/rust-lang/crates.io-index"
162
- checksum = "1cd3927b5a78757a0d71aa9dff669f903b1eb64b54142a9bd9f757f8fde65fd7"
155
+ checksum = "e9b6c2b34cf71427ea37c7001aefbaeb85886a074795e35f161f5aecc7620a7a"
163
156
  dependencies = [
164
157
  "once_cell",
165
158
  "target-lexicon",
@@ -167,9 +160,9 @@ dependencies = [
167
160
 
168
161
  [[package]]
169
162
  name = "pyo3-ffi"
170
- version = "0.23.4"
163
+ version = "0.24.0"
171
164
  source = "registry+https://github.com/rust-lang/crates.io-index"
172
- checksum = "dab6bb2102bd8f991e7749f130a70d05dd557613e39ed2deeee8e9ca0c4d548d"
165
+ checksum = "5507651906a46432cdda02cd02dd0319f6064f1374c9147c45b978621d2c3a9c"
173
166
  dependencies = [
174
167
  "libc",
175
168
  "pyo3-build-config",
@@ -177,47 +170,36 @@ dependencies = [
177
170
 
178
171
  [[package]]
179
172
  name = "quote"
180
- version = "1.0.38"
173
+ version = "1.0.40"
181
174
  source = "registry+https://github.com/rust-lang/crates.io-index"
182
- checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
175
+ checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
183
176
  dependencies = [
184
177
  "proc-macro2",
185
178
  ]
186
179
 
187
- [[package]]
188
- name = "rmp"
189
- version = "0.8.14"
190
- source = "registry+https://github.com/rust-lang/crates.io-index"
191
- checksum = "228ed7c16fa39782c3b3468e974aec2795e9089153cd08ee2e9aefb3613334c4"
192
- dependencies = [
193
- "byteorder",
194
- "num-traits",
195
- "paste",
196
- ]
197
-
198
180
  [[package]]
199
181
  name = "serde"
200
- version = "1.0.218"
182
+ version = "1.0.219"
201
183
  source = "registry+https://github.com/rust-lang/crates.io-index"
202
- checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60"
184
+ checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
203
185
  dependencies = [
204
186
  "serde_derive",
205
187
  ]
206
188
 
207
189
  [[package]]
208
190
  name = "serde_bytes"
209
- version = "0.11.15"
191
+ version = "0.11.17"
210
192
  source = "registry+https://github.com/rust-lang/crates.io-index"
211
- checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a"
193
+ checksum = "8437fd221bde2d4ca316d61b90e337e9e702b3820b87d63caa9ba6c02bd06d96"
212
194
  dependencies = [
213
195
  "serde",
214
196
  ]
215
197
 
216
198
  [[package]]
217
199
  name = "serde_derive"
218
- version = "1.0.218"
200
+ version = "1.0.219"
219
201
  source = "registry+https://github.com/rust-lang/crates.io-index"
220
- checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b"
202
+ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
221
203
  dependencies = [
222
204
  "proc-macro2",
223
205
  "quote",
@@ -238,9 +220,9 @@ checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd"
238
220
 
239
221
  [[package]]
240
222
  name = "syn"
241
- version = "2.0.98"
223
+ version = "2.0.100"
242
224
  source = "registry+https://github.com/rust-lang/crates.io-index"
243
- checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
225
+ checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
244
226
  dependencies = [
245
227
  "proc-macro2",
246
228
  "quote",
@@ -249,15 +231,15 @@ dependencies = [
249
231
 
250
232
  [[package]]
251
233
  name = "target-lexicon"
252
- version = "0.12.16"
234
+ version = "0.13.2"
253
235
  source = "registry+https://github.com/rust-lang/crates.io-index"
254
- checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
236
+ checksum = "e502f78cdbb8ba4718f566c418c52bc729126ffd16baee5baa718cf25dd5a69a"
255
237
 
256
238
  [[package]]
257
239
  name = "unicode-ident"
258
- version = "1.0.17"
240
+ version = "1.0.18"
259
241
  source = "registry+https://github.com/rust-lang/crates.io-index"
260
- checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe"
242
+ checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
261
243
 
262
244
  [[package]]
263
245
  name = "version_check"
@@ -1,13 +1,13 @@
1
1
  [package]
2
2
  name = "ormsgpack"
3
- version = "1.8.0"
3
+ version = "1.9.1"
4
4
  authors = [
5
5
  "Aviram Hassan <aviramyhassan@gmail.com>",
6
6
  "Emanuele Giaquinta <emanuele.giaquinta@gmail.com>",
7
7
  ]
8
8
  description = "Fast, correct Python msgpack library supporting dataclasses, datetimes, and numpy"
9
9
  edition = "2021"
10
- rust-version = "1.70"
10
+ rust-version = "1.81"
11
11
  license = "Apache-2.0 OR MIT"
12
12
  repository = "https://github.com/aviramha/ormsgpack"
13
13
  homepage = "https://github.com/aviramha/ormsgpack"
@@ -40,19 +40,18 @@ unstable-simd = [
40
40
  ahash = { version = "0.8", default-features = false }
41
41
  bytecount = { version = "^0.6.7", default-features = false, features = ["runtime-dispatch-simd"] }
42
42
  byteorder = { version = "1.5.0", default-features = false, features = ["std"] }
43
- chrono = { version = "0.4.39", default-features = false }
43
+ chrono = { version = "0.4.40", default-features = false }
44
44
  half = { version = "2.4.1", default-features = false }
45
45
  itoa = { version = "1", default-features = false }
46
46
  once_cell = { version = "1", default-features = false, features = ["race"] }
47
- pyo3 = { version = "^0.23.4", default-features = false, features = ["extension-module"] }
48
- rmp = { version = "^0.8.14", default-features = false, features = ["std"] }
47
+ pyo3 = { version = "^0.24.0", default-features = false, features = ["extension-module"] }
49
48
  serde = { version = "1", default-features = false }
50
- serde_bytes = { version = "0.11.15", default-features = false, features = ["std"] }
49
+ serde_bytes = { version = "0.11.16", default-features = false, features = ["std"] }
51
50
  simdutf8 = { version = "0.1.5", default-features = false, features = ["std"] }
52
51
  smallvec = { version = "^1.13", default-features = false, features = ["union", "write"] }
53
52
 
54
53
  [build-dependencies]
55
- pyo3-build-config = { version = "^0.23.3" }
54
+ pyo3-build-config = { version = "^0.24.0" }
56
55
 
57
56
  [profile.release]
58
57
  codegen-units = 1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ormsgpack
3
- Version: 1.8.0
3
+ Version: 1.9.1
4
4
  Classifier: Development Status :: 5 - Production/Stable
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: Apache Software License
@@ -371,6 +371,10 @@ TypeError: Type is not msgpack serializable: datetime.datetime
371
371
  b'\x81\xaacreated_at\xbdThu, 01 Jan 1970 00:00:00 GMT'
372
372
  ```
373
373
 
374
+ ##### `OPT_PASSTHROUGH_ENUM`
375
+
376
+ Enable passthrough of `enum.Enum` instances to `default`.
377
+
374
378
  ##### `OPT_PASSTHROUGH_SUBCLASS`
375
379
 
376
380
  Enable passthrough of subclasses of `str`, `int`, `dict` and `list` to
@@ -894,7 +898,7 @@ level above this.
894
898
 
895
899
  ## Packaging
896
900
 
897
- To package ormsgpack requires [Rust](https://www.rust-lang.org/) 1.70
901
+ To package ormsgpack requires [Rust](https://www.rust-lang.org/) 1.81
898
902
  or newer and the [maturin](https://github.com/PyO3/maturin) build
899
903
  tool. The default feature `unstable-simd` enables the usage of SIMD
900
904
  operations and requires nightly Rust. The recommended build command
@@ -339,6 +339,10 @@ TypeError: Type is not msgpack serializable: datetime.datetime
339
339
  b'\x81\xaacreated_at\xbdThu, 01 Jan 1970 00:00:00 GMT'
340
340
  ```
341
341
 
342
+ ##### `OPT_PASSTHROUGH_ENUM`
343
+
344
+ Enable passthrough of `enum.Enum` instances to `default`.
345
+
342
346
  ##### `OPT_PASSTHROUGH_SUBCLASS`
343
347
 
344
348
  Enable passthrough of subclasses of `str`, `int`, `dict` and `list` to
@@ -862,7 +866,7 @@ level above this.
862
866
 
863
867
  ## Packaging
864
868
 
865
- To package ormsgpack requires [Rust](https://www.rust-lang.org/) 1.70
869
+ To package ormsgpack requires [Rust](https://www.rust-lang.org/) 1.81
866
870
  or newer and the [maturin](https://github.com/PyO3/maturin) build
867
871
  tool. The default feature `unstable-simd` enables the usage of SIMD
868
872
  operations and requires nightly Rust. The recommended build command
@@ -28,7 +28,8 @@ dev = [
28
28
  "msgpack",
29
29
  "mypy",
30
30
  "numpy; platform_machine != 'armv7l'",
31
- "pendulum; platform_machine != 'armv7l' and python_version < '3.13'",
31
+ # importing pendulum makes python crash on alpine
32
+ # "pendulum; platform_machine != 'armv7l' and python_version < '3.13'",
32
33
  "pydantic",
33
34
  "pytest",
34
35
  "pytest-benchmark",
@@ -52,11 +53,12 @@ exclude = "benchmarks"
52
53
  strict = true
53
54
 
54
55
  [[tool.mypy.overrides]]
55
- module = ["msgpack"]
56
+ module = ["msgpack", "pendulum"]
56
57
  ignore_missing_imports = true
57
58
 
58
59
  [tool.ruff]
59
60
  line-length = 88
61
+ src = ["python"]
60
62
  target-version = "py39"
61
63
 
62
64
  [tool.ruff.lint]
@@ -74,3 +76,6 @@ ignore = [
74
76
 
75
77
  [tool.ruff.lint.isort]
76
78
  known-first-party = ["ormsgpack"]
79
+
80
+ [project.entry-points.pyinstaller40]
81
+ hook-dirs = "ormsgpack._pyinstaller:get_hook_dirs"
@@ -7,6 +7,7 @@ from .ormsgpack import (
7
7
  OPT_PASSTHROUGH_BIG_INT,
8
8
  OPT_PASSTHROUGH_DATACLASS,
9
9
  OPT_PASSTHROUGH_DATETIME,
10
+ OPT_PASSTHROUGH_ENUM,
10
11
  OPT_PASSTHROUGH_SUBCLASS,
11
12
  OPT_PASSTHROUGH_TUPLE,
12
13
  OPT_PASSTHROUGH_UUID,
@@ -35,6 +36,7 @@ __all__ = (
35
36
  "OPT_PASSTHROUGH_BIG_INT",
36
37
  "OPT_PASSTHROUGH_DATACLASS",
37
38
  "OPT_PASSTHROUGH_DATETIME",
39
+ "OPT_PASSTHROUGH_ENUM",
38
40
  "OPT_PASSTHROUGH_SUBCLASS",
39
41
  "OPT_PASSTHROUGH_TUPLE",
40
42
  "OPT_PASSTHROUGH_UUID",
@@ -24,6 +24,7 @@ OPT_OMIT_MICROSECONDS: int
24
24
  OPT_PASSTHROUGH_BIG_INT: int
25
25
  OPT_PASSTHROUGH_DATACLASS: int
26
26
  OPT_PASSTHROUGH_DATETIME: int
27
+ OPT_PASSTHROUGH_ENUM: int
27
28
  OPT_PASSTHROUGH_SUBCLASS: int
28
29
  OPT_PASSTHROUGH_TUPLE: int
29
30
  OPT_PASSTHROUGH_UUID: int
@@ -0,0 +1,7 @@
1
+ # SPDX-License-Identifier: (Apache-2.0 OR MIT)
2
+
3
+ import os
4
+
5
+
6
+ def get_hook_dirs() -> list[str]:
7
+ return [os.path.dirname(__file__)]
@@ -0,0 +1,7 @@
1
+ # SPDX-License-Identifier: (Apache-2.0 OR MIT)
2
+
3
+ hiddenimports = [
4
+ "dataclasses",
5
+ "enum",
6
+ "uuid",
7
+ ]
@@ -4,11 +4,11 @@ use crate::deserialize::cache::*;
4
4
  use crate::deserialize::DeserializeError;
5
5
  use crate::exc::*;
6
6
  use crate::ffi::*;
7
+ use crate::msgpack::Marker;
7
8
  use crate::opt::*;
8
9
  use crate::typeref::*;
9
10
  use crate::unicode::*;
10
11
  use byteorder::{BigEndian, ReadBytesExt};
11
- use rmp::Marker;
12
12
  use simdutf8::basic::{from_utf8, Utf8Error};
13
13
  use std::borrow::Cow;
14
14
  use std::os::raw::c_char;
@@ -3,4 +3,3 @@
3
3
  pub const INVALID_STR: &str = "str is not valid UTF-8: surrogates not allowed";
4
4
  pub const RECURSION_LIMIT_REACHED: &str = "Recursion limit reached";
5
5
  pub const KEY_MUST_BE_STR: &str = "Dict key must be str";
6
- pub const PYDANTIC_MUST_HAVE_DICT: &str = "Pydantic's BaseModel must have __dict__ attribute";
@@ -1,5 +1,5 @@
1
1
  use pyo3::ffi::*;
2
- use std::os::raw::{c_char, c_int, c_uint, c_void};
2
+ use std::os::raw::{c_int, c_uint, c_void};
3
3
  use std::ptr::null_mut;
4
4
 
5
5
  #[repr(C)]
@@ -18,7 +18,7 @@ unsafe extern "C" fn ext_new(
18
18
  if Py_SIZE(args) != 2 || !kwds.is_null() {
19
19
  PyErr_SetString(
20
20
  PyExc_TypeError,
21
- "Ext.__new__() takes 2 positional arguments\0".as_ptr() as *const c_char,
21
+ c"Ext.__new__() takes 2 positional arguments".as_ptr(),
22
22
  );
23
23
  return null_mut();
24
24
  }
@@ -26,7 +26,7 @@ unsafe extern "C" fn ext_new(
26
26
  if PyLong_Check(tag) == 0 {
27
27
  PyErr_SetString(
28
28
  PyExc_TypeError,
29
- "Ext.__new__() first argument must be int\0".as_ptr() as *const c_char,
29
+ c"Ext.__new__() first argument must be int".as_ptr(),
30
30
  );
31
31
  return null_mut();
32
32
  }
@@ -34,7 +34,7 @@ unsafe extern "C" fn ext_new(
34
34
  if PyBytes_Check(data) == 0 {
35
35
  PyErr_SetString(
36
36
  PyExc_TypeError,
37
- "Ext.__new__() second argument must be bytes\0".as_ptr() as *const c_char,
37
+ c"Ext.__new__() second argument must be bytes".as_ptr(),
38
38
  );
39
39
  return null_mut();
40
40
  }
@@ -69,7 +69,7 @@ pub unsafe fn create_ext_type() -> *mut PyTypeObject {
69
69
  },
70
70
  ];
71
71
  let mut spec = PyType_Spec {
72
- name: "ormsgpack.Ext\0".as_ptr() as *const c_char,
72
+ name: c"ormsgpack.Ext".as_ptr(),
73
73
  basicsize: std::mem::size_of::<PyExt>() as c_int,
74
74
  itemsize: 0,
75
75
  flags: Py_TPFLAGS_DEFAULT as c_uint,
@@ -15,32 +15,34 @@ mod deserialize;
15
15
  mod exc;
16
16
  mod ext;
17
17
  mod ffi;
18
+ mod msgpack;
18
19
  mod opt;
19
20
  mod serialize;
20
21
  mod typeref;
21
22
  mod unicode;
22
23
 
23
24
  use pyo3::ffi::*;
25
+ use std::ffi::CStr;
24
26
  use std::os::raw::c_char;
25
27
  use std::os::raw::c_int;
26
28
  use std::os::raw::c_long;
27
29
  use std::os::raw::c_void;
28
30
  use std::ptr::NonNull;
29
31
 
30
- const PACKB_DOC: &str =
31
- "packb(obj, /, default=None, option=None)\n--\n\nSerialize Python objects to msgpack.\0";
32
- const UNPACKB_DOC: &str =
33
- "unpackb(obj, /, ext_hook=None, option=None)\n--\n\nDeserialize msgpack to Python objects.\0";
32
+ const PACKB_DOC: &CStr =
33
+ c"packb(obj, /, default=None, option=None)\n--\n\nSerialize Python objects to msgpack.";
34
+ const UNPACKB_DOC: &CStr =
35
+ c"unpackb(obj, /, ext_hook=None, option=None)\n--\n\nDeserialize msgpack to Python objects.";
34
36
 
35
37
  macro_rules! module_add_object {
36
38
  ($mptr: expr, $name: expr, $object:expr) => {
37
- PyModule_AddObject($mptr, $name.as_ptr() as *const c_char, $object);
39
+ PyModule_AddObject($mptr, $name.as_ptr(), $object);
38
40
  };
39
41
  }
40
42
 
41
43
  macro_rules! module_add_int {
42
44
  ($mptr:expr, $name:expr, $int:expr) => {
43
- PyModule_AddIntConstant($mptr, $name.as_ptr() as *const c_char, $int as c_long);
45
+ PyModule_AddIntConstant($mptr, $name.as_ptr(), $int as c_long);
44
46
  };
45
47
  }
46
48
 
@@ -50,20 +52,20 @@ macro_rules! module_add_int {
50
52
  pub unsafe extern "C" fn PyInit_ormsgpack() -> *mut PyModuleDef {
51
53
  let methods: Box<[PyMethodDef; 3]> = Box::new([
52
54
  PyMethodDef {
53
- ml_name: "packb\0".as_ptr() as *const c_char,
55
+ ml_name: c"packb".as_ptr(),
54
56
  ml_meth: PyMethodDefPointer {
55
57
  PyCFunctionFastWithKeywords: packb,
56
58
  },
57
59
  ml_flags: METH_FASTCALL | METH_KEYWORDS,
58
- ml_doc: PACKB_DOC.as_ptr() as *const c_char,
60
+ ml_doc: PACKB_DOC.as_ptr(),
59
61
  },
60
62
  PyMethodDef {
61
- ml_name: "unpackb\0".as_ptr() as *const c_char,
63
+ ml_name: c"unpackb".as_ptr(),
62
64
  ml_meth: PyMethodDefPointer {
63
65
  PyCFunctionFastWithKeywords: unpackb,
64
66
  },
65
67
  ml_flags: METH_FASTCALL | METH_KEYWORDS,
66
- ml_doc: UNPACKB_DOC.as_ptr() as *const c_char,
68
+ ml_doc: UNPACKB_DOC.as_ptr(),
67
69
  },
68
70
  PyMethodDef::zeroed(),
69
71
  ]);
@@ -81,7 +83,7 @@ pub unsafe extern "C" fn PyInit_ormsgpack() -> *mut PyModuleDef {
81
83
 
82
84
  let init = Box::new(PyModuleDef {
83
85
  m_base: PyModuleDef_HEAD_INIT,
84
- m_name: "ormsgpack\0".as_ptr() as *const c_char,
86
+ m_name: c"ormsgpack".as_ptr(),
85
87
  m_doc: std::ptr::null(),
86
88
  m_size: 0,
87
89
  m_methods: Box::into_raw(methods) as *mut PyMethodDef,
@@ -102,41 +104,34 @@ pub unsafe extern "C" fn ormsgpack_exec(mptr: *mut PyObject) -> c_int {
102
104
  let version = env!("CARGO_PKG_VERSION");
103
105
  module_add_object!(
104
106
  mptr,
105
- "__version__\0",
107
+ c"__version__",
106
108
  PyUnicode_FromStringAndSize(version.as_ptr() as *const c_char, version.len() as isize)
107
109
  );
108
110
 
109
- module_add_int!(mptr, "OPT_NAIVE_UTC\0", opt::NAIVE_UTC);
110
- module_add_int!(mptr, "OPT_NON_STR_KEYS\0", opt::NON_STR_KEYS);
111
- module_add_int!(mptr, "OPT_OMIT_MICROSECONDS\0", opt::OMIT_MICROSECONDS);
112
- module_add_int!(mptr, "OPT_PASSTHROUGH_BIG_INT\0", opt::PASSTHROUGH_BIG_INT);
111
+ module_add_int!(mptr, c"OPT_NAIVE_UTC", opt::NAIVE_UTC);
112
+ module_add_int!(mptr, c"OPT_NON_STR_KEYS", opt::NON_STR_KEYS);
113
+ module_add_int!(mptr, c"OPT_OMIT_MICROSECONDS", opt::OMIT_MICROSECONDS);
114
+ module_add_int!(mptr, c"OPT_PASSTHROUGH_BIG_INT", opt::PASSTHROUGH_BIG_INT);
113
115
  module_add_int!(
114
116
  mptr,
115
- "OPT_PASSTHROUGH_DATACLASS\0",
117
+ c"OPT_PASSTHROUGH_DATACLASS",
116
118
  opt::PASSTHROUGH_DATACLASS
117
119
  );
118
- module_add_int!(
119
- mptr,
120
- "OPT_PASSTHROUGH_DATETIME\0",
121
- opt::PASSTHROUGH_DATETIME
122
- );
123
- module_add_int!(
124
- mptr,
125
- "OPT_PASSTHROUGH_SUBCLASS\0",
126
- opt::PASSTHROUGH_SUBCLASS
127
- );
128
- module_add_int!(mptr, "OPT_SERIALIZE_NUMPY\0", opt::SERIALIZE_NUMPY);
129
- module_add_int!(mptr, "OPT_SERIALIZE_PYDANTIC\0", opt::SERIALIZE_PYDANTIC);
130
- module_add_int!(mptr, "OPT_PASSTHROUGH_TUPLE\0", opt::PASSTHROUGH_TUPLE);
131
- module_add_int!(mptr, "OPT_SORT_KEYS\0", opt::SORT_KEYS);
132
- module_add_int!(mptr, "OPT_UTC_Z\0", opt::UTC_Z);
133
- module_add_int!(mptr, "OPT_PASSTHROUGH_UUID\0", opt::PASSTHROUGH_UUID);
120
+ module_add_int!(mptr, c"OPT_PASSTHROUGH_DATETIME", opt::PASSTHROUGH_DATETIME);
121
+ module_add_int!(mptr, c"OPT_PASSTHROUGH_ENUM", opt::PASSTHROUGH_ENUM);
122
+ module_add_int!(mptr, c"OPT_PASSTHROUGH_SUBCLASS", opt::PASSTHROUGH_SUBCLASS);
123
+ module_add_int!(mptr, c"OPT_PASSTHROUGH_TUPLE", opt::PASSTHROUGH_TUPLE);
124
+ module_add_int!(mptr, c"OPT_PASSTHROUGH_UUID", opt::PASSTHROUGH_UUID);
125
+ module_add_int!(mptr, c"OPT_SERIALIZE_NUMPY", opt::SERIALIZE_NUMPY);
126
+ module_add_int!(mptr, c"OPT_SERIALIZE_PYDANTIC", opt::SERIALIZE_PYDANTIC);
127
+ module_add_int!(mptr, c"OPT_SORT_KEYS", opt::SORT_KEYS);
128
+ module_add_int!(mptr, c"OPT_UTC_Z", opt::UTC_Z);
134
129
 
135
130
  typeref::init_typerefs();
136
131
 
137
- module_add_object!(mptr, "MsgpackDecodeError\0", typeref::MsgpackDecodeError);
138
- module_add_object!(mptr, "MsgpackEncodeError\0", typeref::MsgpackEncodeError);
139
- module_add_object!(mptr, "Ext\0", typeref::EXT_TYPE as *mut PyObject);
132
+ module_add_object!(mptr, c"MsgpackDecodeError", typeref::MsgpackDecodeError);
133
+ module_add_object!(mptr, c"MsgpackEncodeError", typeref::MsgpackEncodeError);
134
+ module_add_object!(mptr, c"Ext", typeref::EXT_TYPE as *mut PyObject);
140
135
 
141
136
  0
142
137
  }
@@ -0,0 +1,21 @@
1
+ // SPDX-License-Identifier: (Apache-2.0 OR MIT)
2
+
3
+ use crate::msgpack::marker::Marker;
4
+ use byteorder::{BigEndian, WriteBytesExt};
5
+
6
+ pub fn write_array_len<W>(writer: &mut W, len: usize) -> Result<(), std::io::Error>
7
+ where
8
+ W: std::io::Write,
9
+ {
10
+ if len < 16 {
11
+ writer.write_u8(Marker::FixArray(len as u8).into())
12
+ } else if len < 65536 {
13
+ writer.write_u8(Marker::Array16.into())?;
14
+ writer.write_u16::<BigEndian>(len as u16)
15
+ } else if len <= 4294967295 {
16
+ writer.write_u8(Marker::Array32.into())?;
17
+ writer.write_u32::<BigEndian>(len as u32)
18
+ } else {
19
+ Err(std::io::Error::from(std::io::ErrorKind::InvalidInput))
20
+ }
21
+ }
@@ -0,0 +1,24 @@
1
+ // SPDX-License-Identifier: (Apache-2.0 OR MIT)
2
+
3
+ use crate::msgpack::marker::Marker;
4
+ use byteorder::{BigEndian, WriteBytesExt};
5
+
6
+ pub fn write_bin<W>(writer: &mut W, value: &[u8]) -> Result<(), std::io::Error>
7
+ where
8
+ W: std::io::Write,
9
+ {
10
+ let len = value.len();
11
+ if len < 256 {
12
+ writer.write_u8(Marker::Bin8.into())?;
13
+ writer.write_u8(len as u8)?;
14
+ } else if len < 65536 {
15
+ writer.write_u8(Marker::Bin16.into())?;
16
+ writer.write_u16::<BigEndian>(len as u16)?;
17
+ } else if len <= 4294967295 {
18
+ writer.write_u8(Marker::Bin32.into())?;
19
+ writer.write_u32::<BigEndian>(len as u32)?;
20
+ } else {
21
+ return Err(std::io::Error::from(std::io::ErrorKind::InvalidInput));
22
+ }
23
+ writer.write_all(value)
24
+ }
@@ -0,0 +1,13 @@
1
+ // SPDX-License-Identifier: (Apache-2.0 OR MIT)
2
+
3
+ use crate::msgpack::marker::Marker;
4
+ use byteorder::WriteBytesExt;
5
+
6
+ #[inline]
7
+ pub fn write_bool<W>(writer: &mut W, value: bool) -> Result<(), std::io::Error>
8
+ where
9
+ W: std::io::Write,
10
+ {
11
+ let marker = if value { Marker::True } else { Marker::False };
12
+ writer.write_u8(marker.into())
13
+ }