diff --git a/lib/spack/spack/directives.py b/lib/spack/spack/directives.py
index 5b2bf652edabe0aad8b18ebca4318c02fc34c80a..8e9cf4dbcc44e7c8f5324e69587d1fd197e694ae 100644
--- a/lib/spack/spack/directives.py
+++ b/lib/spack/spack/directives.py
@@ -194,7 +194,7 @@ def remove_directives(arg):
                 # Nasty, but it's the best way I can think of to avoid
                 # side effects if directive results are passed as args
                 remove_directives(args)
-                remove_directives(kwargs.values())
+                remove_directives(list(kwargs.values()))
 
                 # A directive returns either something that is callable on a
                 # package or a sequence of them
diff --git a/lib/spack/spack/test/patch.py b/lib/spack/spack/test/patch.py
index 33db0d2a393c61584926622f8c482a1f62cb78c0..bdc67968f618eb6362812a688a155456d198527c 100644
--- a/lib/spack/spack/test/patch.py
+++ b/lib/spack/spack/test/patch.py
@@ -11,6 +11,7 @@
 
 import spack.patch
 import spack.paths
+import spack.repo
 import spack.util.compression
 from spack.util.executable import Executable
 from spack.stage import Stage
@@ -102,6 +103,29 @@ def test_patch_in_spec(mock_packages, config):
             spec.variants['patches'].value)
 
 
+def test_nested_directives(mock_packages):
+    """Ensure pkg data structures are set up properly by nested directives."""
+    # this ensures that the patch() directive results were removed
+    # properly from the DirectiveMeta._directives_to_be_executed list
+    patcher = spack.repo.path.get_pkg_class('patch-several-dependencies')
+    assert len(patcher.patches) == 0
+
+    # this ensures that results of dependency patches were properly added
+    # to Dependency objects.
+    libelf_dep = next(iter(patcher.dependencies['libelf'].values()))
+    assert len(libelf_dep.patches) == 1
+    assert len(libelf_dep.patches[Spec('libelf')]) == 1
+
+    libdwarf_dep = next(iter(patcher.dependencies['libdwarf'].values()))
+    assert len(libdwarf_dep.patches) == 2
+    assert len(libdwarf_dep.patches[Spec('libdwarf')]) == 1
+    assert len(libdwarf_dep.patches[Spec('libdwarf@20111030')]) == 1
+
+    fake_dep = next(iter(patcher.dependencies['fake'].values()))
+    assert len(fake_dep.patches) == 1
+    assert len(fake_dep.patches[Spec('fake')]) == 2
+
+
 def test_patched_dependency(
         mock_packages, config, install_mockery, mock_fetch):
     """Test whether patched dependencies work."""