[Git][NTPsec/ntpsec][master] Fixes unicode bug under python 3
Ian Bruene
gitlab at mg.gitlab.com
Wed Sep 27 22:35:36 UTC 2017
Ian Bruene pushed to branch master at NTPsec / ntpsec
Commits:
c8cb0941 by Ian Bruene at 2017-09-27T17:31:50-05:00
Fixes unicode bug under python 3
ntpq previously failed to properly display unicode characters
Initial fix found by Gary E. Miller gem at rellim.com
- - - - -
1 changed file:
- ntpclients/ntpq
Changes:
=====================================
ntpclients/ntpq
=====================================
--- a/ntpclients/ntpq
+++ b/ntpclients/ntpq
@@ -70,9 +70,6 @@ if str is bytes: # Python 2
def string_escape(s):
return s.decode('string_escape')
- def make_wrapper(fp):
- return fp
-
else: # Python 3
import io
@@ -100,30 +97,6 @@ else: # Python 3
# assumes that it will be called with a Python 3 'str' instance
return s.encode(master_encoding).decode('unicode_escape')
- def make_wrapper(fp):
- "Wrapper factory function to enforce master encoding"
- # This can be used to wrap normally binary streams for API
- # compatibility with functions that need a text stream in
- # Python 3; it ensures that the binary bytes are decoded using
- # the master encoding we use to turn bytes to Unicode in
- # polystr above
- # newline="\n" ensures that Python 3 won't mangle line breaks
- return io.TextIOWrapper(fp, encoding=master_encoding, newline="\n")
-
- def make_std_wrapper(stream):
- "Standard input/output wrapper factory function"
- # This ensures that the encoding of standard output and standard
- # error on Python 3 matches the master encoding we use to turn
- # bytes to Unicode in polystr above
- # line_buffering=True ensures that interactive command sessions
- # work as expected
- return io.TextIOWrapper(stream.buffer, encoding=master_encoding,
- newline="\n", line_buffering=True)
-
- sys.stdin = make_std_wrapper(sys.stdin)
- sys.stdout = make_std_wrapper(sys.stdout)
- sys.stderr = make_std_wrapper(sys.stderr)
-
# NTP-specific parts resume here
# Flags for forming descriptors.
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/c8cb09414a6e141ba48a9a06de82da465b411ec7
---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/c8cb09414a6e141ba48a9a06de82da465b411ec7
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/20170927/c734514c/attachment.html>
More information about the vc
mailing list