From: John Spray Date: Wed, 3 Jun 2015 09:40:32 +0000 (+0100) Subject: pybind: avoid spurious "too many values to unpack" X-Git-Tag: v9.0.2~19^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=232ec887be3af353892ac757ae29be9617f238e4;p=ceph.git pybind: avoid spurious "too many values to unpack" When a user passes e.g. an IP address where they should have passed a ., the dots were causing us to raise "too many values to unpack" exceptions instead of proper complaints about it not being a valid service name. Fixes: #10950 Signed-off-by: John Spray --- diff --git a/src/pybind/ceph_argparse.py b/src/pybind/ceph_argparse.py index 8698c4eb171..762ba604e88 100644 --- a/src/pybind/ceph_argparse.py +++ b/src/pybind/ceph_argparse.py @@ -338,12 +338,12 @@ class CephPgid(CephArgtype): def valid(self, s, partial=False): if s.find('.') == -1: raise ArgumentFormat('pgid has no .') - poolid, pgnum = s.split('.') + poolid, pgnum = s.split('.', 1) if poolid < 0: raise ArgumentFormat('pool {0} < 0'.format(poolid)) try: pgnum = int(pgnum, 16) - except: + except ValueError: raise ArgumentFormat('pgnum {0} not hex integer'.format(pgnum)) self.val = s @@ -370,7 +370,7 @@ class CephName(CephArgtype): if s.find('.') == -1: raise ArgumentFormat('CephName: no . in {0}'.format(s)) else: - t, i = s.split('.') + t, i = s.split('.', 1) if t not in ('osd', 'mon', 'client', 'mds'): raise ArgumentValid('unknown type ' + t) if t == 'osd': @@ -402,7 +402,7 @@ class CephOsdName(CephArgtype): self.val = s return if s.find('.') != -1: - t, i = s.split('.') + t, i = s.split('.', 1) if t != 'osd': raise ArgumentValid('unknown type ' + t) else: