[Git][NTPsec/ntpsec][master] Use specific exceptions instead of using BaseException implicitly

Matt Selsky gitlab at mg.gitlab.com
Fri Dec 28 04:43:47 UTC 2018


Matt Selsky pushed to branch master at NTPsec / ntpsec


Commits:
61f9e1de by Matt Selsky at 2018-12-28T04:27:46Z
Use specific exceptions instead of using BaseException implicitly

- - - - -


3 changed files:

- ntpclients/ntplogtemp.py
- ntpclients/ntpq.py
- pylib/statfiles.py


Changes:

=====================================
ntpclients/ntplogtemp.py
=====================================
@@ -180,7 +180,7 @@ class Temper:
                 now = int(time.time())
                 data.append('%d %s %s' % (now, _device, temp))
                 break
-            except:
+            except ValueError:
                 # bad data, ignore it, for a bit
                 if args.verbose:
                     sys.stderr.write("TEMPer-poll failed\n")


=====================================
ntpclients/ntpq.py
=====================================
@@ -606,7 +606,7 @@ usage: hostnames [yes|no]
                 logfp = open(line, "a", 1)  # 1 => line buffered
                 self.logfp = self.session.logfp = logfp
                 print("Logfile set to", line)
-            except:
+            except IOError:
                 print("Could not open", line, "for logging.")
 
     def help_debug(self):


=====================================
pylib/statfiles.py
=====================================
@@ -40,7 +40,7 @@ class NTPStats:
                 split = line.split()
                 mjd = int(split[0])
                 second = float(split[1])
-            except:
+            except ValueError:
                 # unparseable, skip this line
                 continue
 
@@ -179,7 +179,7 @@ class NTPStats:
 
                 try:
                     time_float = float(split[0])
-                except:
+                except ValueError:
                     # ignore comment lines, lines with no time
                     continue
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/61f9e1de6a998a38f9a7b5c4cbf4f333cde73110

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/61f9e1de6a998a38f9a7b5c4cbf4f333cde73110
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20181228/c89ed06e/attachment-0001.html>


More information about the vc mailing list