Repository: angr/angr

Issue:
Importing ABC from collections module is deprecated
Importing ABC from collections module was deprecated since Python 3.4 and removed in Python 3.9. Instances of this as below. I would like to raise a PR for this.

```
angr/knowledge_plugins/functions/function_manager.py
61:class FunctionManager(KnowledgeBasePlugin, collections.Mapping):
angr/knowledge_plugins/functions/function_manager.py
61:class FunctionManager(KnowledgeBasePlugin, collections.Mapping):
angr/sim_variable.py
232:class SimVariableSet(collections.MutableSet):
```


Discussion:
Yeah, this is something that should be fixed. You can submit that PR!

On Sat, Jan 4, 2020 at 12:21 PM Xtreak <notifications@github.com> wrote:

> Importing ABC from collections module was deprecated since Python 3.4 and
> removed in Python 3.9. Instances of this as below. I would like to raise a
> PR for this.
>
> angr/knowledge_plugins/functions/function_manager.py
> 61:class FunctionManager(KnowledgeBasePlugin, collections.Mapping):
> angr/knowledge_plugins/functions/function_manager.py
> 61:class FunctionManager(KnowledgeBasePlugin, collections.Mapping):
> angr/sim_variable.py
> 232:class SimVariableSet(collections.MutableSet):
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/angr/angr/issues/1903?email_source=notifications&email_token=AATCB5PU7WPBIHVENICIPIDQ4DOTFA5CNFSM4KCXQRF2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IEA6SDQ>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AATCB5N6BKZJSNYULZSQCATQ4DOTFANCNFSM4KCXQRFQ>
> .
>

I'd like to take this! @tirkarthi are these the only instances of collections import you were able to find in the codebase? If there are more I'd happily fix those as well 😄 
One more instance. Using grep to analyze the call sites helps. Thanks.

```
angr/vaults.py
45:class Vault(collections.MutableMapping):
```
Since this project is py3 only, I shouldn't have to take care of py2 edge cases, should be simple enough, right?

Resolving patch:
diff --git a/angr/knowledge_plugins/functions/function_manager.py b/angr/knowledge_plugins/functions/function_manager.py
--- a/angr/knowledge_plugins/functions/function_manager.py
+++ b/angr/knowledge_plugins/functions/function_manager.py
@@ -1,5 +1,5 @@
 import logging
-import collections
+import collections.abc
 from sortedcontainers import SortedDict
 import networkx
 
@@ -58,7 +58,7 @@ def ceiling_addr(self, addr):
             raise KeyError(addr)
 
 
-class FunctionManager(KnowledgeBasePlugin, collections.Mapping):
+class FunctionManager(KnowledgeBasePlugin, collections.abc.Mapping):
     """
     This is a function boundaries management tool. It takes in intermediate
     results during CFG generation, and manages a function map of the binary.
diff --git a/angr/sim_variable.py b/angr/sim_variable.py
--- a/angr/sim_variable.py
+++ b/angr/sim_variable.py
@@ -1,4 +1,4 @@
-import collections
+import collections.abc
 import claripy
 
 class SimVariable:
@@ -229,7 +229,7 @@ def __hash__(self):
         return hash((self.ident, self.base, self.offset, self.size))
 
 
-class SimVariableSet(collections.MutableSet):
+class SimVariableSet(collections.abc.MutableSet):
     """
     A collection of SimVariables.
     """
diff --git a/angr/vaults.py b/angr/vaults.py
--- a/angr/vaults.py
+++ b/angr/vaults.py
@@ -1,4 +1,4 @@
-import collections
+import collections.abc
 import contextlib
 import tempfile
 import weakref
@@ -42,7 +42,7 @@ def __init__(self, vault, file, *args, **kwargs):
     def persistent_load(self, pid):
         return self.vault.load(pid)
 
-class Vault(collections.MutableMapping):
+class Vault(collections.abc.MutableMapping):
     """
     The vault is a serializer for angr.
     """


Test patch: