# Buggy code
def _satisfies_target(self, other_target, strict):
    self_target = self.target

    need_to_check = (
        bool(other_target)
        if strict or self.concrete
        else bool(other_target and self_target)
    )

    # If there's no need to check we are fine
    if not need_to_check:
        return True

    for target_range in str(other_target).split(","):
        t_min, sep, t_max = target_range.partition(":")

        # Checking against a single specific target
        if not sep and self_target == t_min:
            return True

        if not sep and self_target != t_min:
            return False

        # Check against a range
        min_ok = self_target.microarchitecture >= t_min if t_min else True
        max_ok = self_target.microarchitecture <= t_max if t_max else True

        if min_ok and max_ok:
            return True

    return False


# Traceback (AttributeError)
Traceback (most recent call last):
File "/root/spack/bin/spack", line 64, in <module>
sys.exit(spack.main.main())
File "/root/spack/lib/spack/spack/main.py", line 763, in main
return _invoke_command(command, parser, args, unknown)
File "/root/spack/lib/spack/spack/main.py", line 488, in _invoke_command
return_val = command(parser, args)
File "/root/spack/lib/spack/spack/cmd/install.py", line 273, in install
concretized_specs = env.concretize()
File "/root/spack/lib/spack/spack/environment.py", line 948, in concretize
return self._concretize_separately()
File "/root/spack/lib/spack/spack/environment.py", line 1016, in _concretize_separately
concrete = _concretize_from_constraints(uspec_constraints)
File "/root/spack/lib/spack/spack/environment.py", line 1554, in _concretize_from_constraints
return s.concretized()
File "/root/spack/lib/spack/spack/spec.py", line 2298, in concretized
clone.concretize()
File "/root/spack/lib/spack/spack/spec.py", line 2148, in concretize
user_spec_deps=user_spec_deps),
File "/root/spack/lib/spack/spack/spec.py", line 2626, in normalize
visited, all_spec_deps, provider_index, tests)
File "/root/spack/lib/spack/spack/spec.py", line 2552, in _normalize_helper
dep = self._evaluate_dependency_conditions(dep_name)
File "/root/spack/lib/spack/spack/spec.py", line 2375, in _evaluate_dependency_conditions
if self.satisfies(when_spec, strict=True):
File "/root/spack/lib/spack/spack/spec.py", line 2879, in satisfies
if not self.architecture.satisfies(other.architecture, strict):
File "/root/spack/lib/spack/spack/spec.py", line 360, in satisfies
return self._satisfies_target(other.target, strict=strict)
File "/root/spack/lib/spack/spack/spec.py", line 383, in _satisfies_target
min_ok = self_target.microarchitecture >= t_min if t_min else True
AttributeError: 'NoneType' object has no attribute 'microarchitecture'

# Fixed code
def _satisfies_target(self, other_target, strict):
    self_target = self.target

    need_to_check = (
        bool(other_target)
        if strict or self.concrete
        else bool(other_target and self_target)
    )

    # If there's no need to check we are fine
    if not need_to_check:
        return True

    # self is not concrete, but other_target is there and strict=True
    if self.target is None:
        return False

    for target_range in str(other_target).split(","):
        t_min, sep, t_max = target_range.partition(":")

        # Checking against a single specific target
        if not sep and self_target == t_min:
            return True

        if not sep and self_target != t_min:
            return False

        # Check against a range
        min_ok = self_target.microarchitecture >= t_min if t_min else True
        max_ok = self_target.microarchitecture <= t_max if t_max else True

        if min_ok and max_ok:
            return True

    return False