From 16a8e3771b3df4f522af0829cb043a4604714776 Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Thu, 18 Jun 2020 16:53:14 +0100 Subject: [PATCH] Objects: Make bool an int We can't inherit from bool, so __new__ can't return a bool, so everything has be done with int. However __bool__ is already defined for int, so it should have no significant impact (other than type() calls). Fixes issue 232. --- volatility/framework/objects/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/volatility/framework/objects/__init__.py b/volatility/framework/objects/__init__.py index 5d4c70886..c7760d4d3 100644 --- a/volatility/framework/objects/__init__.py +++ b/volatility/framework/objects/__init__.py @@ -156,9 +156,12 @@ class PrimitiveObject(interfaces.objects.ObjectInterface): return self._context.layers.write(self.vol.layer_name, self.vol.offset, data) +# This must be int (and the _struct_type must be int) because bool cannot be inherited from: +# https://mail.python.org/pipermail/python-dev/2002-March/020822.html +# https://mail.python.org/pipermail/python-dev/2004-February/042537.html class Boolean(PrimitiveObject, int): """Primitive Object that handles boolean types.""" - _struct_type = bool # type: ClassVar[Type] + _struct_type = int # type: ClassVar[Type] class Integer(PrimitiveObject, int):