[Git][NTPsec/ntpsec][master] Added python 2 utf-8 output enforcer

Ian Bruene gitlab at mg.gitlab.com
Thu Sep 28 22:04:29 UTC 2017


Ian Bruene pushed to branch master at NTPsec / ntpsec


Commits:
7cf48106 by Ian Bruene at 2017-09-28T17:04:00-05:00
Added python 2 utf-8 output enforcer

- - - - -


1 changed file:

- ntpclients/ntpq


Changes:

=====================================
ntpclients/ntpq
=====================================
--- a/ntpclients/ntpq
+++ b/ntpclients/ntpq
@@ -21,6 +21,7 @@ import resource
 import socket
 import sys
 import time
+import codecs
 
 try:
     import ntp.control
@@ -67,6 +68,13 @@ if str is bytes:  # Python 2
     def string_escape(s):
         return s.decode('string_escape')
 
+    if sys.stdout.encoding != "UTF-8":
+        forced_utf8 = True
+        sys.stdout = codecs.getwriter('UTF-8')(sys.stdout)
+    if sys.stderr.encoding != "UTF-8":
+        forced_utf8 = True
+        sys.stderr = codecs.getwriter('UTF-8')(sys.stderr)
+
 else:  # Python 3
     import io
 



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

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/7cf481060af952131b5a8042487ee12cf6fc9cc1
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/20170928/03c18a0e/attachment.html>


More information about the vc mailing list