Skip to content

Commit

Permalink
Get rid of the wrapt library
Browse files Browse the repository at this point in the history
We only were using `wrapt` in a single place -- to implement the
`unimplemented` syscall decorator.  That dependency was added in #1384,
so that the old syscall mechanism could work with the decorator.

Now, with the rework of Manticore's syscall mechanism, this is no longer
necessary, and a "regular" Python decorator implemented using
`functools.wraps` should work just fine.
  • Loading branch information
Brad Larsen committed Apr 21, 2020
1 parent 4ee5e26 commit 59c4de6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
27 changes: 15 additions & 12 deletions manticore/platforms/platform.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import wrapt
import logging
from ..utils.event import Eventful

from functools import wraps
from typing import Callable, Dict, Tuple

logger = logging.getLogger(__name__)
Expand All @@ -11,17 +11,20 @@ class OSException(Exception):
pass


@wrapt.decorator
def unimplemented(wrapped: Callable, _instance, args: Tuple, kwargs: Dict):
cpu = getattr(getattr(_instance, "parent", None), "current", None)
addr_str = "" if cpu is None else f" at {hex(cpu.read_register('PC'))}"
logger.warning(
f"Unimplemented system call: %s: %s(%s)",
addr_str,
wrapped.__name__,
", ".join(hex(a) if isinstance(a, int) else str(a) for a in args),
)
return wrapped(*args, **kwargs)
def unimplemented(wrapped: Callable) -> Callable:
@wraps(wrapped)
def new_wrapped(*args, **kwargs):
cpu = getattr(getattr(_instance, "parent", None), "current", None)
addr_str = "" if cpu is None else f" at {hex(cpu.read_register('PC'))}"
logger.warning(
f"Unimplemented system call: %s: %s(%s)",
addr_str,
wrapped.__name__,
", ".join(hex(a) if isinstance(a, int) else str(a) for a in args),
)
return wrapped(*args, **kwargs)

return new_wrapped


class SyscallNotImplemented(OSException):
Expand Down
3 changes: 0 additions & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ ignore_missing_imports = True
[mypy-prettytable.*]
ignore_missing_imports = True

[mypy-wrapt.*]
ignore_missing_imports = True

[mypy-wasm.*]
ignore_missing_imports = True

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def rtd_dependent_deps():
python_requires=">=3.6",
install_requires=[
"pyyaml",
"wrapt",
# evm dependencies
"pysha3",
"prettytable",
Expand Down

0 comments on commit 59c4de6

Please sign in to comment.