From 28c19a38c9dca7ebdd56c80b7a6233f2b476c58b Mon Sep 17 00:00:00 2001 From: Robert Nishihara Date: Wed, 14 Sep 2016 14:21:24 -0700 Subject: [PATCH] Catch incorrect arguments to PlasmaClient constructor. (#18) --- lib/python/plasma.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/python/plasma.py b/lib/python/plasma.py index b3b772f13..8a114f294 100644 --- a/lib/python/plasma.py +++ b/lib/python/plasma.py @@ -31,6 +31,12 @@ class PlasmaClient(object): addr (str): IPv4 address of plasma manager attached to the plasma store. port (int): Port number of the plasma manager attached to the plasma store. """ + if port is not None: + if not isinstance(port, int): + raise Exception("The 'port' argument must be an integer. The given argument has type {}.".format(type(port))) + if not 0 < port < 65536: + raise Exception("The 'port' argument must be greater than 0 and less than 65536. The given value is {}.".format(port)) + plasma_client_library = os.path.join(os.path.abspath(os.path.dirname(__file__)), "../../build/plasma_client.so") self.client = ctypes.cdll.LoadLibrary(plasma_client_library)