dissect.cstruct 4.0.dev0__py3-none-any.whl → 4.0.dev2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -299,4 +299,7 @@ class Expression:
299
299
 
300
300
  self.evaluate_exp()
301
301
 
302
+ if len(self.queue) != 1:
303
+ raise ExpressionParserError("Invalid expression")
304
+
302
305
  return self.queue[0]
@@ -11,6 +11,7 @@ if TYPE_CHECKING:
11
11
 
12
12
 
13
13
  PY_311 = sys.version_info >= (3, 11, 0)
14
+ PY_312 = sys.version_info >= (3, 12, 0)
14
15
 
15
16
 
16
17
  class EnumMetaType(EnumMeta, MetaType):
@@ -56,6 +57,13 @@ class EnumMetaType(EnumMeta, MetaType):
56
57
 
57
58
  __len__ = MetaType.__len__
58
59
 
60
+ if not PY_312:
61
+ # Backport __contains__ from CPython 3.12
62
+ def __contains__(cls, value: Any) -> bool:
63
+ if isinstance(value, cls):
64
+ return True
65
+ return value in cls._value2member_map_
66
+
59
67
  def _read(cls, stream: BinaryIO, context: dict[str, Any] = None) -> Enum:
60
68
  return cls(cls.type._read(stream, context))
61
69
 
@@ -174,10 +182,7 @@ class Enum(BaseType, IntEnum, metaclass=EnumMetaType):
174
182
  @classmethod
175
183
  def _missing_(cls, value: int) -> Enum:
176
184
  # Emulate FlagBoundary.KEEP for enum (allow values other than the defined members)
177
- pseudo_member = cls._value2member_map_.get(value, None)
178
- if pseudo_member is None:
179
- new_member = int.__new__(cls, value)
180
- new_member._name_ = None
181
- new_member._value_ = value
182
- pseudo_member = cls._value2member_map_.setdefault(value, new_member)
183
- return pseudo_member
185
+ new_member = int.__new__(cls, value)
186
+ new_member._name_ = None
187
+ new_member._value_ = value
188
+ return new_member
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dissect.cstruct
3
- Version: 4.0.dev0
3
+ Version: 4.0.dev2
4
4
  Summary: A Dissect module implementing a parser for C-like structures: structure parsing in Python made easy
5
5
  Author-email: Dissect Team <dissect@fox-it.com>
6
6
  License: Apache License 2.0
@@ -3,13 +3,13 @@ dissect/cstruct/bitbuffer.py,sha256=phqKSE-BS8crZ_sdzssF3E831bD5Gk8LOXIE7iQJXa8,
3
3
  dissect/cstruct/compiler.py,sha256=MYhlvXqhXwrjov5SFO3i8eftdsvjdrIXszQrflr6kQU,13810
4
4
  dissect/cstruct/cstruct.py,sha256=W-17FFc8OM2je7VTMMVQc-hivCAjaRj9qSdf4cEDrCY,14851
5
5
  dissect/cstruct/exceptions.py,sha256=WqsUW4OiIpRLQLvixfLrfKl0rtvU1qx7pvfBrz9Sz-I,293
6
- dissect/cstruct/expression.py,sha256=8IHZuAV-t5Fx1-qhCAB1he8yYEk8tOOqpYIaY_iom3I,10667
6
+ dissect/cstruct/expression.py,sha256=giBNkbFgsbsw2K2EvQi42GRlm9Z97UvhDhcHnNMG2dg,10763
7
7
  dissect/cstruct/parser.py,sha256=ozMbJ1Ihf6igaD5vTkkIg5H8N_I8_-lc7tyjWy92m5E,20806
8
8
  dissect/cstruct/utils.py,sha256=rSCFW04eUgD04n-WZ6z_wTnu7JLT9tGRY9rU0BIC4_w,10297
9
9
  dissect/cstruct/types/__init__.py,sha256=basF3huZ-jOg4FqGQGW7-SmYDN2GuMuCQN21asLtelQ,855
10
10
  dissect/cstruct/types/base.py,sha256=qZeXn1MAEb-vOlF4HdeqbMHx4-Mr5lTcHYt_s0lhu9g,8944
11
11
  dissect/cstruct/types/char.py,sha256=M_QmYL8c96bIO8r2nxHC26zXoPjO2dMtehoWtZJL2M8,2397
12
- dissect/cstruct/types/enum.py,sha256=DJxHm8FzogrEx0w-rMAz6NKPet1R84OoJWFBhcXzxnQ,6616
12
+ dissect/cstruct/types/enum.py,sha256=1P-GUSRLWAKRcn55XhPYvK9KVMdX3x7GdmdDUy2HuEQ,6701
13
13
  dissect/cstruct/types/flag.py,sha256=EOJVk-5G7aUtD6plg7_Y6yxoAcrAQCNMjxoUePEQukk,2345
14
14
  dissect/cstruct/types/int.py,sha256=pBdr9InRY3EMHlULBmzBZCI2Qdh2XygsUelDWBrIRhc,1067
15
15
  dissect/cstruct/types/leb128.py,sha256=yHkWqcGEWkf-8ZzfLv_5p937fzrMRvlZXwxowEl36CU,2168
@@ -18,9 +18,9 @@ dissect/cstruct/types/pointer.py,sha256=kWfEBCgW7TDnJihZiDGUlldD3QSxVY19r8LGz7ol
18
18
  dissect/cstruct/types/structure.py,sha256=Pqdo4IjdF-XzTVTtDZqu9EUTxdsQ1a5HwAEgF9HbLg8,23954
19
19
  dissect/cstruct/types/void.py,sha256=RGBlM1yBYCFUM9yLyOETMZBd_nEp9-6vH5xFXaphK8o,438
20
20
  dissect/cstruct/types/wchar.py,sha256=5kap4GDypRmt5IoLhMnREbWaWTEMhY_xVLCFginbwFo,2536
21
- dissect.cstruct-4.0.dev0.dist-info/COPYRIGHT,sha256=H-18RXfshdH9AdHwW2eO1Xa-5s6tY5eipHh5c0whDu4,316
22
- dissect.cstruct-4.0.dev0.dist-info/LICENSE,sha256=PhUqiw6jAh2KbBdVRPBq_hfAvfcTBin7nZ3CK7NQbTM,11341
23
- dissect.cstruct-4.0.dev0.dist-info/METADATA,sha256=Htou7UwmHT6Ov3DmGCg0cK9kRCFyHewtVJpW5IgBJts,8303
24
- dissect.cstruct-4.0.dev0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
25
- dissect.cstruct-4.0.dev0.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
26
- dissect.cstruct-4.0.dev0.dist-info/RECORD,,
21
+ dissect.cstruct-4.0.dev2.dist-info/COPYRIGHT,sha256=H-18RXfshdH9AdHwW2eO1Xa-5s6tY5eipHh5c0whDu4,316
22
+ dissect.cstruct-4.0.dev2.dist-info/LICENSE,sha256=PhUqiw6jAh2KbBdVRPBq_hfAvfcTBin7nZ3CK7NQbTM,11341
23
+ dissect.cstruct-4.0.dev2.dist-info/METADATA,sha256=EJQTgpQ_60wUCcHxQ2d1cqBK7FYjpuIL7T67XG2N-58,8303
24
+ dissect.cstruct-4.0.dev2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
25
+ dissect.cstruct-4.0.dev2.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
26
+ dissect.cstruct-4.0.dev2.dist-info/RECORD,,