Repository: angr/angr

Issue:
Several undefined names
As reported in #1001 

```
./angr/analyses/cfg/indirect_jump_resolvers/resolver.py:56:20: F821 undefined name 'SimMemoryError'
            except SimMemoryError:
                   ^
./angr/procedures/linux_loader/__tls_get_addr.py:8:19: F821 undefined name 'SimValueError'
            raise SimValueError("__tls_get_addr called with symbolic module ID")
                  ^
./angr/storage/paged_memory.py:239:21: F821 undefined name 'items'
                    items.insert(0, key)
                    ^
./tests/broken_FindAvoidConflict.py:29:20: F821 undefined name 'AngrError'
            except AngrError:
                   ^
./tests/test_file_struct_funcs.py:42:5: F821 undefined name 'run_test_file_struct_funcs'
    run_test_file_struct_funcs()
    ^
./tests/test_signed_div.py:28:5: F821 undefined name 'run_signed_div'
    run_signed_div()
    ^
```


Discussion:

Resolving patch:
diff --git a/angr/analyses/cfg/indirect_jump_resolvers/resolver.py b/angr/analyses/cfg/indirect_jump_resolvers/resolver.py
--- a/angr/analyses/cfg/indirect_jump_resolvers/resolver.py
+++ b/angr/analyses/cfg/indirect_jump_resolvers/resolver.py
@@ -1,4 +1,6 @@
 
+from ....errors import SimMemoryError
+
 
 class IndirectJumpResolver(object):
     def __init__(self, project, timeless=False, base_state=None):
diff --git a/angr/procedures/linux_loader/__tls_get_addr.py b/angr/procedures/linux_loader/__tls_get_addr.py
--- a/angr/procedures/linux_loader/__tls_get_addr.py
+++ b/angr/procedures/linux_loader/__tls_get_addr.py
@@ -1,4 +1,6 @@
 import angr
+from angr.errors import SimValueError
+
 
 class __tls_get_addr(angr.SimProcedure):
     # pylint: disable=arguments-differ
diff --git a/angr/storage/paged_memory.py b/angr/storage/paged_memory.py
--- a/angr/storage/paged_memory.py
+++ b/angr/storage/paged_memory.py
@@ -236,7 +236,7 @@ def load_slice(self, state, start, end):
                 pass
             else:
                 if self._storage[key].includes(start):
-                    items.insert(0, key)
+                    keys.insert(0, key)
         return [(key, self._storage[key]) for key in keys]
 
     def _copy_args(self):


Test patch:
diff --git a/tests/broken_FindAvoidConflict.py b/tests/broken_FindAvoidConflict.py
--- a/tests/broken_FindAvoidConflict.py
+++ b/tests/broken_FindAvoidConflict.py
@@ -26,7 +26,7 @@ def test_FindAvoidConflict():
         for addr in path.addr_trace:
             try:
                 instAddrs = set(proj.factory.block(addr).instruction_addrs)
-            except AngrError:
+            except angr.errors.AngrError:
                 instAddrs = {}
             assert (avoidAddr not in instAddrs)
 
diff --git a/tests/test_file_struct_funcs.py b/tests/test_file_struct_funcs.py
--- a/tests/test_file_struct_funcs.py
+++ b/tests/test_file_struct_funcs.py
@@ -1,12 +1,14 @@
 import nose
 import angr
 
+import os
 import logging
+
 l = logging.getLogger('angr.tests.test_file_struct_funcs')
 
-import os
 test_location = str(os.path.dirname(os.path.realpath(__file__)))
 
+
 def check_state_1(state):
     # Need to dump file.txt by path because program closes it
     return state.posix.dump_file_by_path('file.txt') == "testing abcdef" and \
@@ -14,18 +16,21 @@ def check_state_1(state):
            state.posix.dumps(1) == "good1\n" and \
            state.posix.dumps(2) == ""
 
+
 def check_state_2(state):
     return state.posix.dump_file_by_path('file.txt') == "testing abcdef" and \
            state.posix.dumps(0)[:4] == "wxyz" and \
            state.posix.dumps(1) == "" and \
            state.posix.dumps(2) == "good2\n"
 
+
 def check_state_3(state):
     return state.posix.dump_file_by_path('file.txt') == "testing abcdef" and \
            state.posix.dumps(1) == "" and \
            state.posix.dumps(2) == ""
 
-def test_test_file_struct_funcs():
+
+def test_file_struct_funcs():
     test_bin = os.path.join(test_location, "../../binaries/tests/x86_64/file_func_test")
     b = angr.Project(test_bin)
 
@@ -38,5 +43,6 @@ def test_test_file_struct_funcs():
     for p in pg.deadended:
         nose.tools.assert_true(check_state_1(p) or check_state_2(p) or check_state_3(p))
 
+
 if __name__ == "__main__":
-    run_test_file_struct_funcs()
+    test_file_struct_funcs()
diff --git a/tests/test_signed_div.py b/tests/test_signed_div.py
--- a/tests/test_signed_div.py
+++ b/tests/test_signed_div.py
@@ -25,4 +25,4 @@ def test_signed_div():
     nose.tools.assert_equal(out_angr, stdout_real)
 
 if __name__ == "__main__":
-    run_signed_div()
+    test_signed_div()