viff

changeset 1304:0c57d87411b9

Raise correct error for abstract methods. The NotImplemented value is a special return value used in operator overloading -- the exception we want is called NotImplementedError.
author Martin Geisler <mg@cs.au.dk>
date Fri, 25 Sep 2009 11:30:58 +0200
parents deb7659465d2
children abe1bf5198b3
files apps/benchmark_classes.py viff/runtime.py
diffstat 2 files changed, 9 insertions(+), 9 deletions(-) [+]
line diff
     1.1 --- a/apps/benchmark_classes.py	Mon Oct 19 11:48:08 2009 +0200
     1.2 +++ b/apps/benchmark_classes.py	Fri Sep 25 11:30:58 2009 +0200
     1.3 @@ -87,7 +87,7 @@
     1.4          return sync
     1.5  
     1.6      def run_test(self, _):
     1.7 -        raise NotImplemented("Override this abstract method in a sub class.")
     1.8 +        raise NotImplementedError
     1.9  
    1.10      def finished(self, needed_data, termination_function):
    1.11          sys.stdout.flush()
    1.12 @@ -155,7 +155,7 @@
    1.13  
    1.14          Returns: None.
    1.15          """
    1.16 -        raise NotImplemented("Override this abstract method in subclasses")
    1.17 +        raise NotImplementedError
    1.18  
    1.19      def is_operation_done(self):
    1.20          """Returns true if there are no more operations to perform.
    1.21 @@ -163,14 +163,14 @@
    1.22  
    1.23          Returns: Boolean.
    1.24          """
    1.25 -        raise NotImplemented("Override this abstract method in subclasses")
    1.26 +        raise NotImplementedError
    1.27  
    1.28      def do_operation(self):
    1.29          """Perform the operation.
    1.30  
    1.31          Returns: A share containing the result of the operation.
    1.32          """
    1.33 -        raise NotImplemented("Override this abstract method in subclasses")
    1.34 +        raise NotImplementedError
    1.35  
    1.36  class BinaryOperation(Operation):
    1.37      """A binary operation."""
    1.38 @@ -220,7 +220,7 @@
    1.39      """A benchmark strategy defines how the benchmark is done."""
    1.40  
    1.41      def benchmark(self, *args):
    1.42 -        raise NotImplemented("Override this abstract method in subclasses")
    1.43 +        raise NotImplementedError
    1.44  
    1.45  
    1.46  class SelfcontainedBenchmarkStrategy(BenchmarkStrategy):
     2.1 --- a/viff/runtime.py	Mon Oct 19 11:48:08 2009 +0200
     2.2 +++ b/viff/runtime.py	Fri Sep 25 11:30:58 2009 +0200
     2.3 @@ -863,7 +863,7 @@
     2.4          listed in *inputters*, then a :class:`Share` is given back
     2.5          directly.
     2.6          """
     2.7 -        raise NotImplemented("Override this abstract method in a subclass.")
     2.8 +        raise NotImplementedError
     2.9  
    2.10      def output(self, share, receivers=None):
    2.11          """Open *share* to *receivers* (defaults to all players).
    2.12 @@ -871,7 +871,7 @@
    2.13          Returns a :class:`Share` to players with IDs in *receivers*
    2.14          and :const:`None` to the remaining players.
    2.15          """
    2.16 -        raise NotImplemented("Override this abstract method in a subclass.")
    2.17 +        raise NotImplementedError
    2.18  
    2.19      def add(self, share_a, share_b):
    2.20          """Secure addition.
    2.21 @@ -879,7 +879,7 @@
    2.22          At least one of the arguments must be a :class:`Share`, the
    2.23          other can be a :class:`FieldElement` or a (possible long)
    2.24          Python integer."""
    2.25 -        raise NotImplemented("Override this abstract method in a subclass.")
    2.26 +        raise NotImplementedError
    2.27  
    2.28      def mul(self, share_a, share_b):
    2.29          """Secure multiplication.
    2.30 @@ -887,7 +887,7 @@
    2.31          At least one of the arguments must be a :class:`Share`, the
    2.32          other can be a :class:`FieldElement` or a (possible long)
    2.33          Python integer."""
    2.34 -        raise NotImplemented("Override this abstract method in a subclass.")
    2.35 +        raise NotImplementedError
    2.36  
    2.37      def handle_deferred_data(self, deferred, data):
    2.38          """Put deferred and data into the queue if the ViffReactor is running.