[llvm] r189549 - [lit] Change lit.Test.ResultCode to be unique across pickling.
Daniel Dunbar
daniel at zuster.org
Wed Aug 28 17:48:39 PDT 2013
Author: ddunbar
Date: Wed Aug 28 19:48:39 2013
New Revision: 189549
URL: http://llvm.org/viewvc/llvm-project?rev=189549&view=rev
Log:
[lit] Change lit.Test.ResultCode to be unique across pickling.
Modified:
llvm/trunk/utils/lit/lit/Test.py
Modified: llvm/trunk/utils/lit/lit/Test.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/Test.py?rev=189549&r1=189548&r2=189549&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/Test.py (original)
+++ llvm/trunk/utils/lit/lit/Test.py Wed Aug 28 19:48:39 2013
@@ -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
More information about the llvm-commits
mailing list