[Git][NTPsec/ntpsec][master] ntpq downgrades to non-unicode instead of forcing the issue.

Ian Bruene gitlab at mg.gitlab.com
Tue Jan 2 18:32:05 UTC 2018


Ian Bruene pushed to branch master at NTPsec / ntpsec


Commits:
fdf95030 by Ian Bruene at 2018-01-02T12:30:45-06:00
ntpq downgrades to non-unicode instead of forcing the issue.

This fixes the command history problem.

- - - - -


1 changed file:

- ntpclients/ntpq.py


Changes:

=====================================
ntpclients/ntpq.py
=====================================
--- a/ntpclients/ntpq.py
+++ b/ntpclients/ntpq.py
@@ -61,18 +61,17 @@ version = ntp.util.stdversion()
 forced_utf8 = False
 
 if str is bytes:  # Python 2
-    import codecs
-
     polystr = unicode
     polybytes = bytes
 
     def string_escape(s):
         return s.decode('string_escape')
 
-    # Originally these only triggered if sys.stdout.encoding != "UTF-8":
-    # Unfortunately sometimes sys.stdout.encoding lies
-    sys.stdout = codecs.getwriter('UTF-8')(sys.stdout)
-    sys.stderr = codecs.getwriter('UTF-8')(sys.stderr)
+    # This used to force UTF-8 encoding, but that breaks the readline system.
+    # Unfortunately sometimes sys.stdout.encoding lies about the encoding,
+    # so expect random false positives.
+    if sys.stdout.encoding != "UTF-8":
+        ntp.util.deunicode_units()
 
 else:  # Python 3
     import io



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

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/fdf95030546ec9c5d2ea0cfe2f460fde780bab33
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/20180102/357b229c/attachment.html>


More information about the vc mailing list