[Git][NTPsec/ntpsec][master] Fixed string error in __parse_varlist

Ian Bruene gitlab at mg.gitlab.com
Thu Aug 24 19:56:32 UTC 2017


Ian Bruene pushed to branch master at NTPsec / ntpsec


Commits:
3b9ce3c5 by Ian Bruene at 2017-08-24T14:55:40-05:00
Fixed string error in __parse_varlist

- - - - -


1 changed file:

- pylib/packet.py


Changes:

=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -1289,20 +1289,21 @@ class ControlSession:
             key, value = key.strip(), value.strip()
             # Start trying to cast to non-string types
             # I don't like this block, look for a less ugly method
-            try:
-                castedvalue = int(value, 0)
-            except ValueError:
+            if value:
                 try:
-                    castedvalue = float(value)
-                    if (key == "delay") and (raw is False):
-                        # Hack for non-raw-mode to get precision
-                        items.append(("delay-s", value))
+                    castedvalue = int(value, 0)
                 except ValueError:
-                    if (value[0] == '"') and (value[-1] == '"'):
-                        value = value[1:-1]
-                        castedvalue = value  # for uniform tuples
-                    else:  # fell through everything else, still need casted
-                        castedvalue = value
+                    try:
+                        castedvalue = float(value)
+                        if (key == "delay") and (raw is False):
+                            # Hack for non-raw-mode to get precision
+                            items.append(("delay-s", value))
+                    except ValueError:
+                        if (value[0] == '"') and (value[-1] == '"'):
+                            value = value[1:-1]
+                        castedvalue = value  # str / unknown, stillneed casted
+            else:  # no value
+                castedvalue = value
             if raw is True:
                 items.append((key, (castedvalue, value)))
             else:



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/3b9ce3c5b239ef78f67b158acf0707e68e5b38c4

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/3b9ce3c5b239ef78f67b158acf0707e68e5b38c4
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/20170824/396a001c/attachment.html>


More information about the vc mailing list