From: Radoslaw Zarzynski Date: Wed, 28 Jan 2015 16:09:20 +0000 (+0100) Subject: pybind: fix error hiding and inconsistency on librados load. X-Git-Tag: v0.93~109^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F3565%2Fhead;p=ceph.git pybind: fix error hiding and inconsistency on librados load. When loading of librados failed, the real cause was hidden in some circumstances due to exception rewriting. Additionally, the error reporting was inconsistent -- two paths with different exceptions and messages existed. Fixes: #7264 Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/pybind/rados.py b/src/pybind/rados.py index b50b67ce392c..5d2c150a4724 100644 --- a/src/pybind/rados.py +++ b/src/pybind/rados.py @@ -203,17 +203,10 @@ Rados object in state %s." % self.state) def __init__(self, rados_id=None, name=None, clustername=None, conf_defaults=None, conffile=None, conf=None, flags=0): - librados_path = find_library('rados') - if not librados_path: - #maybe find_library can not find it correctly on all platforms. - try: - self.librados = CDLL('librados.so.2') - except OSError as e: - raise EnvironmentError("Unable to load librados: %s" % e) - except: - raise Error("Unexpected error") - else: - self.librados = CDLL(librados_path) + library_path = find_library('rados') + # maybe find_library can not find it correctly on all platforms, + # so fall back to librados.so.2 in such case. + self.librados = CDLL(library_path if library_path is not None else 'librados.so.2') self.parsed_args = [] self.conf_defaults = conf_defaults