Skip to content

Commit

Permalink
AutoMod RuleTarget __init__: don't be destructive
Browse files Browse the repository at this point in the history
Since part of RuleTarget.__init__() involves deleting items from the
values dict, this actually changed the dict that was passed to it, which
could have side effects back in the overall Rule creation. Specifically,
this was causing the approve_banned initialization to fail because it
tried to check for the presence of a key that had been destroyed by
this.
  • Loading branch information
Deimos committed May 4, 2015
1 parent a9c5925 commit 276ae94
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions r2/r2/lib/automoderator.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ def __init__(self, target_type, values, parent, approve_banned=True):

if not values:
values = {}
else:
values = values.copy()

# determine patterns that will be matched against fields
self.match_patterns = self.get_match_patterns(values)
Expand Down

0 comments on commit 276ae94

Please sign in to comment.