Skip to content

Commit

Permalink
Fixed issue with offset fields not removing keep_pos flag
Browse files Browse the repository at this point in the history
---

+ bumped to version 1.0.0-b3
  • Loading branch information
MatrixEditor committed Apr 26, 2024
1 parent c456a11 commit ad479cd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion caterpillar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

__version__ = "1.0.0-b1"
__version__ = "1.0.0-b3"
__release__ = None
__author__ = "MatrixEditor"
8 changes: 6 additions & 2 deletions caterpillar/fields/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,12 @@ def __matmul__(self, offset: Union[_ContextLambda, int]) -> Self:
self.offset = offset
# This operation automatically removes the "keep_position"
# flag. It has to be set manually.
if self.offset != -1:
self.flags.pop(F_KEEP_POSITION, None)
# NOTE: The check does not need to be done if the given value
# is a context lambda. Otherwise it would add the __ne__ operation
# to the context lambda, which would be an unintended side effect.
if isinstance(self.offset, int) and self.offset != -1:
# pylint: disable-next=protected-access
self.flags.pop(F_KEEP_POSITION._hash_, None)
return self

def __getitem__(self, dim: Union[_ContextLambda, int, _GreedyType]) -> Self:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
# requires-python = ">= 3.12"
name = "caterpillar"
version = "1.0.0-b2"
version = "1.0.0-b3"

description="Library to pack and unpack structurized binary data."
authors = [
Expand Down

0 comments on commit ad479cd

Please sign in to comment.