Skip to content

Commit

Permalink
[lit] Change lit.Test.ResultCode to be unique across pickling.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189549 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
ddunbar committed Aug 29, 2013
1 parent aee279d commit 8253cc0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions utils/lit/lit/Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
class ResultCode(object):
"""Test result codes."""

# We override __new__ and __getnewargs__ to ensure that pickling still
# provides unique ResultCode objects in any particular instance.
_instances = {}
def __new__(cls, name, isFailure):
res = cls._instances.get(name)
if res is None:
cls._instances[name] = res = super(ResultCode, cls).__new__(cls)
return res
def __getnewargs__(self):
return (self.name, self.isFailure)

def __init__(self, name, isFailure):
self.name = name
self.isFailure = isFailure
Expand Down

0 comments on commit 8253cc0

Please sign in to comment.