Skip to content

Commit

Permalink
Make generator cloning a little bit more robust
Browse files Browse the repository at this point in the history
Now Manticore will give up and return the original argument instead of blowing up if it can't clone the generator
  • Loading branch information
Eric Hennenfent committed Aug 5, 2020
1 parent 34f5ecb commit 201f585
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions manticore/utils/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,14 @@ def _publish(self, _name, *args, can_raise=True, **kwargs):
# Separate from _publish since the recursive method call to forward an event
# shouldn't check the event.
def _publish_impl(self, _name, *args, **kwargs):
bucket_items = self._get_signal_bucket(_name).items()

for robj, methods in bucket_items:
bucket = self._get_signal_bucket(_name)
for robj, methods in bucket.items():
for callback in methods:
# Need to clone any iterable args, otherwise the first usage will drain it
# Need to clone any iterable args, otherwise the first usage will drain it.
# If the generator isn't available on `self`, give up and return it anyway.
new_args = (
(arg if not isgenerator(arg) else getattr(self, arg.__name__)) for arg in args
(arg if not isgenerator(arg) else getattr(self, arg.__name__, arg))
for arg in args
)
callback(robj(), *new_args, **kwargs)

Expand Down

0 comments on commit 201f585

Please sign in to comment.