[Git][NTPsec/ntpsec][master] 2 commits: Changed unnecessesarily snarky and factually inaccurate comment.
Ian Bruene
gitlab at mg.gitlab.com
Thu Sep 28 15:34:22 UTC 2017
Ian Bruene pushed to branch master at NTPsec / ntpsec
Commits:
cbf3a54a by Ian Bruene at 2017-09-28T10:19:49-05:00
Changed unnecessesarily snarky and factually inaccurate comment.
- - - - -
db68a834 by Ian Bruene at 2017-09-28T10:32:20-05:00
Restored IO wrapper for OSX ascii streams.
- - - - -
2 changed files:
- ntpclients/ntpq
- tests/pylib/jigs.py
Changes:
=====================================
ntpclients/ntpq
=====================================
--- a/ntpclients/ntpq
+++ b/ntpclients/ntpq
@@ -89,6 +89,33 @@ 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)
+
+ if sys.stdin.encoding == "ascii":
+ sys.stdin = make_std_wrapper(sys.stdin)
+ if sys.stdout.encoding == "ascii":
+ sys.stdout = make_std_wrapper(sys.stdout)
+ if sys.stderr.encoding == "ascii":
+ sys.stderr = make_std_wrapper(sys.stderr)
+
# NTP-specific parts resume here
# Flags for forming descriptors.
=====================================
tests/pylib/jigs.py
=====================================
--- a/tests/pylib/jigs.py
+++ b/tests/pylib/jigs.py
@@ -184,7 +184,7 @@ class SocketModuleJig:
EAI_NONAME = socket.EAI_NONAME
if hasattr(socket, "EAI_NODATA"):
EAI_NODATA = socket.EAI_NODATA
- else: # FreeBSD is speschul
+ else: # FreeBSD does not have EAI_NODATA (removed from POSIX)
EAI_NODATA = None
NI_NAMEREQD = socket.NI_NAMEREQD
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/df9d118f51f4d553d9757a0de49678418e0971d1...db68a83469284cae233676c48c7fc62a619ac934
---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/df9d118f51f4d553d9757a0de49678418e0971d1...db68a83469284cae233676c48c7fc62a619ac934
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/1f63b972/attachment.html>
More information about the vc
mailing list