mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-25 13:35:10 +00:00
[lit] Change lit.Test.ResultCode to be unique across pickling.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189549 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
aee279dad5
commit
8253cc047d
@ -5,6 +5,17 @@ import os
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user