[Git][NTPsec/ntpsec][master] Fix for "'str' object does not support item assignment" error.

Eric S. Raymond gitlab at mg.gitlab.com
Sun Nov 27 12:47:03 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
c422df5f by Eric S. Raymond at 2016-11-27T07:46:43-05:00
Fix for "'str' object does not support item assignment" error.

- - - - -


1 changed file:

- pylib/packet.py


Changes:

=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -1104,19 +1104,19 @@ class ControlSession:
         # Strip out NULs and binary garbage from text;
         # ntpd seems prone to generate these, especially
         # in reslist responses.
+        instring = False
         response = ""
         for c in self.response:
-            if polyord(c) > 0 and polyord(c) < 127:
-                response += c
+            if c == '"':
+                response = response + c
+                instring = not instring
+            if instring and c == ',':
+                response = response + "\xae"
+            elif polyord(c) > 0 and polyord(c) < 127:
+                response = response + c
         response = response.rstrip()
         items = []
         if response:
-            instring = False
-            for i in range(len(response)):
-                if response[i] == '"':
-                    instring = not instring
-                elif instring and response[i] == ',':
-                    response[i] = "\xae"
             for pair in response.split(","):
                 try:
                     pair = pair.strip()



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/c422df5f12ef2864afdc44dd7c12e17d76782c99
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161127/47caed49/attachment.html>


More information about the vc mailing list