-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed filter issue and exception bug
- Loading branch information
Showing
5 changed files
with
58 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from dynapyt.analyses.BaseAnalysis import BaseAnalysis | ||
from dynapyt.instrument.filters import only | ||
|
||
|
||
class TestAnalysis(BaseAnalysis): | ||
@only(patterns=["foo"]) | ||
def pre_call(self, dyn_ast: str, iid: int, function, pos_args, kw_args) -> None: | ||
print(f"pree call of {function.__name__}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pree call of deferred_error | ||
pree call of ValueError | ||
pree call of new | ||
pree call of DeferredError | ||
pree call of print | ||
OK | ||
# Exception: Some error text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class DeferredError: | ||
def __init__(self, ex: BaseException): | ||
self.ex = ex | ||
|
||
def __getattr__(self, elt: str) -> None: | ||
raise self.ex | ||
|
||
@staticmethod | ||
def new(ex: BaseException): | ||
""" | ||
Creates an object that raises the wrapped exception ``ex`` when used. | ||
""" | ||
return DeferredError(ex) | ||
|
||
|
||
def deferred_error() -> None: | ||
thing = DeferredError.new(ValueError("Some error text")) | ||
print("OK") | ||
x = thing.some_attr | ||
print("Not OK") | ||
|
||
|
||
deferred_error() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters