(self)
| 271 | pass |
| 272 | |
| 273 | def test_loads_recursion(self): |
| 274 | def run_tests(N, check): |
| 275 | # (((...None...),),) |
| 276 | check(b')\x01' * N + b'N') |
| 277 | check(b'(\x01\x00\x00\x00' * N + b'N') |
| 278 | # [[[...None...]]] |
| 279 | check(b'[\x01\x00\x00\x00' * N + b'N') |
| 280 | # {None: {None: {None: ...None...}}} |
| 281 | check(b'{N' * N + b'N' + b'0' * N) |
| 282 | # frozenset([frozenset([frozenset([...None...])])]) |
| 283 | check(b'>\x01\x00\x00\x00' * N + b'N') |
| 284 | # Check that the generated marshal data is valid and marshal.loads() |
| 285 | # works for moderately deep nesting |
| 286 | run_tests(100, marshal.loads) |
| 287 | # Very deeply nested structure shouldn't blow the stack |
| 288 | def check(s): |
| 289 | self.assertRaises(ValueError, marshal.loads, s) |
| 290 | run_tests(2**20, check) |
| 291 | |
| 292 | def test_recursion_limit(self): |
| 293 | # Create a deeply nested structure. |
nothing calls this directly
no test coverage detected