diff options
author | Fred Wright <fw@fwright.net> | 2016-12-24 17:00:20 -0800 |
---|---|---|
committer | Fred Wright <fw@fwright.net> | 2016-12-25 12:53:04 -0800 |
commit | adcba9ae23b8bce85cf7f3f25e6b30113d7a1e5a (patch) | |
tree | 483de8d842a87ae21f0bafb0cc6ff9d7d68284ea /gpsfake | |
parent | 04ac607bcf742785f08feef5e3f8ce4a85858a05 (diff) | |
download | gpsd-adcba9ae23b8bce85cf7f3f25e6b30113d7a1e5a.tar.gz |
Changes fake.py stream type to 'bytes'.
Given that the data returned bye fake.py may include binary data,
'bytes' is a more appropriate type. Unlike the client API, where it's
easy to provide both return types, it would be less convenient to do
that here, so 'bytes' is preferred as the one choice (and is
consistent with network sockets).
When sending such data to stdout (or stderr), the straightforward
method is to write to sys.stdXXX.buffer rather than sys.stdXXX. That
doesn't exist in Python 2, but a helper function is now provided to
get the appropriate 'bytes' stream for stdXXX.
Since no previous *release* of GPSD is compatible with Python 3,
changing this now doesn't break anything based on released code.
TESTED:
Ran "scons check" on OSX with all supported Python versions.
Diffstat (limited to 'gpsfake')
-rwxr-xr-x | gpsfake | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -28,8 +28,8 @@ try: except NameError: my_input = input -# Make sure stdout can accept binary data in Python 3 -sys.stdout = gps.make_std_wrapper(sys.stdout) +# Get version of stdout for bytes data (NOP in Python 2) +bytesout = gps.get_bytes_stream(sys.stdout) class Baton(object): "Ship progress indications to stderr." @@ -197,7 +197,7 @@ if __name__ == '__main__': predump=predump, slow=slow) if pipe: - test.reporter = sys.stdout.write + test.reporter = bytesout.write if verbose: progress = False test.progress = sys.stderr.write |