[PATCH/rhel6-branch] Handle NoneType Exception after deleting PPC partitions (#1021445)

Vratislav Podzimek vpodzime at redhat.com
Tue Feb 10 08:34:13 UTC 2015


On Fri, 2015-02-06 at 14:17 -0500, Robert Marshall wrote:
> Users reported that the installer would crash when deleting all
> existing partitions on the PowerPC Platform. This crash occurred
> because the installer preferentially looks for a PRePBoot on the
> same partition as /boot and, if it couldn't find any partitions
> assigned to the /boot mount point, the object containing
> boot devices would be null and the subsequent calls to that
> object would trigger the failure. Modified the code such that
> it checks if the value is NoneType and, if it is, simply skip
> the codeblock that performs the preferential lookup. Updated the
> type check for mdarray to validate the presence of the type
> attribute so that, if the boot device object does not include
> the type attribute, it will pick the sane default as intended.
> 
> Resolves rhbz#1021445
> ---
>  booty/ppc.py | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/booty/ppc.py b/booty/ppc.py
> index 2cb2103..d7184ba 100644
> --- a/booty/ppc.py
> +++ b/booty/ppc.py
> @@ -6,6 +6,7 @@ from util import getDiskPart
>  from bootloaderInfo import *
>  import iutil
>  import parted
> +import types
>  
>  class ppcBootloaderInfo(bootloaderInfo):
>      def pickPReP(self):
> @@ -27,13 +28,16 @@ class ppcBootloaderInfo(bootloaderInfo):
>  
>          # we'd prefer a PReP partition that's on the same disk as /boot.
>          bootdev = self.storage.mountpoints.get("/boot",self.storage.rootDevice)
> -        if bootdev.type == "mdarray":
> -            bootdisks = set(p.disk for p in bootdev.parents)
> -        else:
> -            bootdisks = set([bootdev.disk])
> -        for dev in prepdevs:
> -            if dev.disk in bootdisks:
> -                return dev
> +
> +	# If the /boot drive was deleted then bootdev will be NoneType
> +	if not isinstance(bootdev, types.NoneType):
The NoneType has the only instance which is None. So instead of testing
bootdev for being instance of NoneType, it's easier and less complicated
to just use 'if bootdev is not None' or a more generic test 'if bootdev'
which also catches empty lists, strings,...

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list