Fix a issue may caused by attacked_text.py #693
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Delete a repeat save parameters, it can lead to code in no response in some situation
Summary
Lines 404 and 474 of the code store the same parameters, so delete line 474.
If two identical parameters are saved at the same time, a long list of "prev_attacked_text" needs to be maintained internally when call
get_transformations
multiple times to generatetransformed_texts
.__eq__
function inAttackedText
class is called repeatedly each time whether thetransformed_texts
exists inconstraints_cache
, and__eq__
function compares all parameters item by item. If comparing "prev_attacked_text" with "previous_ attacked_text" will enter the linked list saved by each other, sometimes the layers are very deep, the code can get stuck for a long time comparing them, eventually the code will not continue to run normally.Deletions
new_attack_attrs["prev_attacked_text"] = self