Skip to content

Commit 1e48186

Browse files
committed
pwclient: Resolve pycode warnings
Either catch the specific exceptions or, in two cases, remove unnecessary error-handling code. Modified to include fix from commit aa30424. Signed-off-by: Stephen Finucane <[email protected]> Reviewed-by: Daniel Axtens <[email protected]> (cherry picked from commit 5816009)
1 parent fbf47b8 commit 1e48186

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

patchwork/bin/pwclient

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ def patch_id_from_hash(rpc, project, hash):
388388
# be super paranoid
389389
try:
390390
patch_id = int(patch_id)
391-
except:
391+
except ValueError:
392392
sys.stderr.write("Invalid patch ID obtained from server\n")
393393
sys.exit(1)
394394
return patch_id
@@ -434,13 +434,11 @@ def main():
434434
help='''Filter by delegate (name, e-mail substring search)'''
435435
)
436436
filter_parser.add_argument(
437-
'-n', metavar='MAX#',
438-
type=int,
437+
'-n', metavar='MAX#', type=int,
439438
help='''Return first n results'''
440439
)
441440
filter_parser.add_argument(
442-
'-N', metavar='MAX#',
443-
type=int,
441+
'-N', metavar='MAX#', type=int,
444442
help='''Return last N results'''
445443
)
446444
filter_parser.add_argument(
@@ -613,16 +611,10 @@ installed locales.
613611
'Must specify one or more update options (-a or -s)')
614612

615613
if args.get('n') is not None:
616-
try:
617-
filt.add("max_count", args.get('n'))
618-
except:
619-
action_parser.error("Invalid maximum count '%s'" % args.get('n'))
614+
filt.add("max_count", args.get('n'))
620615

621616
if args.get('N') is not None:
622-
try:
623-
filt.add("max_count", 0 - args.get('N'))
624-
except:
625-
action_parser.error("Invalid maximum count '%s'" % args.get('N'))
617+
filt.add("max_count", 0 - args.get('N'))
626618

627619
do_signoff = args.get('signoff')
628620
do_three_way = args.get('3way')
@@ -668,7 +660,7 @@ installed locales.
668660
if not project_str:
669661
try:
670662
project_str = config.get('options', 'default')
671-
except:
663+
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
672664
action_parser.error(
673665
"No default project configured in %s\n" % CONFIG_FILE)
674666

@@ -717,7 +709,7 @@ installed locales.
717709

718710
try:
719711
rpc = xmlrpclib.Server(url, transport=transport)
720-
except:
712+
except (IOError, OSError):
721713
sys.stderr.write("Unable to connect to %s\n" % url)
722714
sys.exit(1)
723715

0 commit comments

Comments
 (0)