Skip to content

Commit

Permalink
During mapping store, all slice mappings is re-calculated to slices
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Stepanov <penguinolog@gmail.com>
  • Loading branch information
penguinolog committed Dec 9, 2016
1 parent b009094 commit 26cf6cc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions binfield/binfield.py
Expand Up @@ -618,8 +618,6 @@ def __getitem__(self, item):
return self._getslice_(slice(idx, idx + 1), name=item)
if isinstance(idx, slice):
return self._getslice_(idx, name=item)
if isinstance(idx, (tuple, list)):
return self._getslice_(slice(*idx), name=item)

if isinstance(idx, dict): # Nested _mapping_
# Extract slice
Expand Down Expand Up @@ -691,6 +689,11 @@ def _set_bit_(self, key, value):
self._value_ = mask | value << key

def __setitem__(self, key, value):
"""Indexed setter
:type key: union(str, int, slice, list, tuple)
:type value: int
"""
if not isinstance(value, int):
raise TypeError(
'BinField value could be set only as int'
Expand All @@ -712,7 +715,7 @@ def __setitem__(self, key, value):
raise IndexError("Mapping is not available")

idx = self._mapping_.get(key)
if isinstance(idx, (int, slice, tuple)):
if isinstance(idx, (int, slice)):
return self.__setitem__(idx, value)

if isinstance(
Expand Down

0 comments on commit 26cf6cc

Please sign in to comment.