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

Brian C. Lane bcl at redhat.com
Tue Feb 10 16:24:19 UTC 2015


On Fri, Feb 06, 2015 at 02:17:33PM -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):
> +	    bootdisks = set([bootdev.disk])
> +	    if hasattr(bootdev, 'type'):
> +		if bootdev.type == "mdarray":
> +		    bootdisks = set(p.disk for p in bootdev.parents)
> +	    for dev in prepdevs:
> +		if dev.disk in bootdisks:
> +		    return dev
>  
>          # failing that, return the first PReP partition we found
>          return prepdevs[0]
> -- 
> 2.1.0

Sorry, I meant to look at this again sooner. I agree with vpodzime about
None, no need to use isinstance, is not None is also easier to read.

I also move that first bootdisks into an else: clause instead of setting
it one way and then maybe setting it the other. Make it explicit :)

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)


More information about the anaconda-patches mailing list