|
2 | 2 | import sys |
3 | 3 | import struct |
4 | 4 | from io import open, BytesIO, SEEK_CUR, SEEK_END # noqa |
| 5 | +import warnings |
5 | 6 |
|
6 | 7 | PY2 = sys.version_info[0] == 2 |
7 | 8 |
|
@@ -322,9 +323,17 @@ def read_bits_int_be(self, n): |
322 | 323 |
|
323 | 324 | return res |
324 | 325 |
|
325 | | - # Unused since Kaitai Struct Compiler v0.9+ - compatibility with |
326 | | - # older versions. |
327 | 326 | def read_bits_int(self, n): |
| 327 | + """Deprecated and no longer used as of KSC 0.9. It is only available |
| 328 | + for backwards compatibility and will be removed in the future. |
| 329 | +
|
| 330 | + KSC 0.9 and later uses `read_bits_int_be()` instead. |
| 331 | + """ |
| 332 | + warnings.warn( |
| 333 | + "read_bits_int() is deprecated since 0.9, use read_bits_int_be() instead", |
| 334 | + DeprecationWarning, |
| 335 | + stacklevel=2, |
| 336 | + ) |
328 | 337 | return self.read_bits_int_be(n) |
329 | 338 |
|
330 | 339 | def read_bits_int_le(self, n): |
@@ -457,6 +466,18 @@ def read_bytes_term_multi(self, term, include_term, consume_term, eos_error): |
457 | 466 | r += c |
458 | 467 |
|
459 | 468 | def ensure_fixed_contents(self, expected): |
| 469 | + """Deprecated and no longer used as of KSC 0.9. It is only available |
| 470 | + for backwards compatibility and will be removed in the future. |
| 471 | +
|
| 472 | + KSC 0.9 and later explicitly raises `ValidationNotEqualError` from an |
| 473 | + `if` statement instead. |
| 474 | + """ |
| 475 | + warnings.warn( |
| 476 | + "ensure_fixed_contents() is deprecated since 0.9, explicitly raise " |
| 477 | + "ValidationNotEqualError from an `if` statement instead", |
| 478 | + DeprecationWarning, |
| 479 | + stacklevel=2, |
| 480 | + ) |
460 | 481 | actual = self._io.read(len(expected)) |
461 | 482 | if actual != expected: |
462 | 483 | raise Exception( |
|
0 commit comments