Skip to content

Commit 67ffcff

Browse files
committed
Raise DeprecationWarning from deprecated methods
1 parent d0058ac commit 67ffcff

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

kaitaistruct.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import sys
33
import struct
44
from io import open, BytesIO, SEEK_CUR, SEEK_END # noqa
5+
import warnings
56

67
PY2 = sys.version_info[0] == 2
78

@@ -322,9 +323,17 @@ def read_bits_int_be(self, n):
322323

323324
return res
324325

325-
# Unused since Kaitai Struct Compiler v0.9+ - compatibility with
326-
# older versions.
327326
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+
)
328337
return self.read_bits_int_be(n)
329338

330339
def read_bits_int_le(self, n):
@@ -457,6 +466,18 @@ def read_bytes_term_multi(self, term, include_term, consume_term, eos_error):
457466
r += c
458467

459468
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+
)
460481
actual = self._io.read(len(expected))
461482
if actual != expected:
462483
raise Exception(

0 commit comments

Comments
 (0)