From 0c09c84360fef6a411f62ba9351812c56503fb24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Tue, 2 Mar 2021 11:18:58 +0100 Subject: [PATCH] fixed Python 2 compatibility Python 2 returns the string representation with just calling writeframes(data) instead of writeframes(data.tostring()) /tmp/post.wav 0000 0000: 52 49 46 46 C4 AA 00 00 57 41 56 45 66 6D 74 20 RIFF.... WAVEfmt 0000 0010: 10 00 00 00 01 00 01 00 80 BB 00 00 00 77 01 00 ........ .....w.. 0000 0020: 02 00 10 00 64 61 74 61 A0 AA 00 00 61 72 72 61 ....data ....arra 0000 0030: 79 28 27 68 27 2C 20 5B 30 2C 20 38 30 36 35 2C y('h', [ 0, 8065, 0000 0040: 20 31 35 36 33 35 2C 20 32 32 32 34 32 2C 20 32 15635, 22242, 2 This change adds an escape hatch that could work for both major Python versions, except Python 3.0 and 3.1 but those should be rare and unsupported anyway. --- pysstv/sstv.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pysstv/sstv.py b/pysstv/sstv.py index 1ffe7f3..e69f020 100644 --- a/pysstv/sstv.py +++ b/pysstv/sstv.py @@ -4,6 +4,7 @@ from __future__ import division, with_statement from six.moves import range from six.moves import map from six.moves import zip +from six import PY3 from math import sin, pi from random import random from contextlib import closing @@ -54,7 +55,7 @@ class SSTV(object): wav.setnchannels(self.nchannels) wav.setsampwidth(self.bits // 8) wav.setframerate(self.samples_per_sec) - wav.writeframes(data) + wav.writeframes(data if PY3 else data.tostring()) def gen_samples(self): """generates discrete samples from gen_values()