(self, diff=1)
| 550 | return self.context_objects.get(id(key), default) |
| 551 | |
| 552 | def increase_depth(self, diff=1): |
| 553 | # Depth accounting is paired on the successful path only. |
| 554 | # If a nested read raises, the top-level deserialize/reset path clears |
| 555 | # `depth`, so nested readers must not add local try/finally wrappers |
| 556 | # around increase/decrease pairs. |
| 557 | self.depth += diff |
| 558 | if self.depth > self.max_depth: |
| 559 | raise Exception( |
| 560 | f"Read depth exceed max depth: {self.depth}, the deserialization data may be malicious. If it's not malicious, " |
| 561 | "please increase max read depth by Fory(..., max_depth=...)" |
| 562 | ) |
| 563 | |
| 564 | def decrease_depth(self, diff=1): |
| 565 | # Only call this after the matching nested read completed successfully. |
no outgoing calls
no test coverage detected