Repository navigation
Commit 43f7e2b
committed
fix(reassembly): make Deferred picklable under protocol 0 and 1 (#2423)
Deferred declares __slots__ with no __getstate__/__setstate__, so protocol
0 and 1 (which copyreg refuses outright once __getstate__ is still the
inherited default) raised TypeError for any Deferred instance, regardless
of its analyze/proto/payload values. Independent of #2417, a different
concern on the same class.
A cross-review before this merged raised two more defects on the same fix
(#2425), both folded in here:
- __getstate__ now mirrors the (dict_or_None, slots) pair Python's own
default slotted-class reduction already produced for every released
build, instead of a bespoke flat dict. A Deferred pickled by any
released version still unpickles, and __setstate__ additionally still
accepts the first revision's own flat shape.
- both methods walk type(self).__mro__ rather than reading
self.__slots__ directly, which resolves through the MRO like any other
attribute and so silently dropped the base class's slots under a
subclass declaring its own.
Covered by tests/foundation/reassembly/test_deferred_pickle_2423_unit.py,
pinning protocol 0/1, the native state shape, backward compatibility with
both pickle shapes, and MRO-aware subclassing (unset slots, a __weakref__
slot, a subclass with a bare __dict__). Confirmed every new/changed test
fails against each prior revision by temporarily stashing just the
relevant code change and re-running.
Build: brazil-build not applicable (GitHub project); ran coverage run -m
pytest, mypy and pylint with this project's own CI flags, and isort --
all clean on the touched files.
Closes #2423
Closes #24251 parent 867616b commit 43f7e2b
4 files changed
Lines changed: 414 additions & 1 deletion
File tree
- docs/source/changelog
- pcapkit/foundation/reassembly/data
- tests/foundation/reassembly
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| 181 | + | |
181 | 182 | | |
182 | 183 | | |
183 | 184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1262 | 1262 | | |
1263 | 1263 | | |
1264 | 1264 | | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
1265 | 1275 | | |
1266 | 1276 | | |
1267 | 1277 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
209 | 273 | | |
210 | 274 | | |
211 | 275 | | |
| |||
0 commit comments