Skip to content

Commit 2b35dfc

Browse files
committed
Remove Python 2.x support
1 parent 14de398 commit 2b35dfc

File tree

3 files changed

+21
-29
lines changed

3 files changed

+21
-29
lines changed

.travis.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,26 @@ matrix:
66
- python: "3.7"
77
- python: "3.6"
88
- python: "3.5"
9-
- python: "2.7"
109
- python: "nightly"
1110
- python: "pypy3"
1211
- os: osx
1312
language: generic
1413
- name: build docs and check for broken links
1514
install:
16-
- pip install -r doc/requirements.txt
15+
- python3 -m pip install -r doc/requirements.txt
1716
script:
18-
- python setup.py build_sphinx -b linkcheck -W
17+
- python3 setup.py build_sphinx -b linkcheck -W
1918
addons:
2019
apt:
2120
packages:
2221
- pandoc
2322
- libportaudio2
2423
install:
25-
- pip install .
24+
- python3 -m pip install .
2625
script:
2726
- cd /tmp
28-
- python -m sounddevice
29-
- python -c "import sounddevice as sd; print(sd._libname)"
30-
- python -c "import sounddevice as sd; print(sd.get_portaudio_version())"
27+
- python3 -m sounddevice
28+
- python3 -c "import sounddevice as sd; print(sd._libname)"
29+
- python3 -c "import sounddevice as sd; print(sd.get_portaudio_version())"
3130
notifications:
3231
email: false

setup.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
break
1111

1212
PYTHON_INTERPRETERS = '.'.join([
13-
'cp26', 'cp27',
1413
'cp32', 'cp33', 'cp34', 'cp35', 'cp36', 'cp37', 'cp38', 'cp39',
15-
'pp27',
1614
'pp32', 'pp33', 'pp34', 'pp35', 'pp36', 'pp37',
1715
])
1816
MACOSX_VERSIONS = '.'.join([
@@ -50,7 +48,7 @@ class bdist_wheel_half_pure(bdist_wheel):
5048
"""Create OS-dependent, but Python-independent wheels."""
5149

5250
def get_tag(self):
53-
pythons = 'py2.py3.' + PYTHON_INTERPRETERS
51+
pythons = 'py3.' + PYTHON_INTERPRETERS
5452
if system == 'Darwin':
5553
oses = MACOSX_VERSIONS
5654
elif system == 'Windows':
@@ -59,7 +57,7 @@ def get_tag(self):
5957
else:
6058
oses = 'win_amd64'
6159
else:
62-
pythons = 'py2.py3'
60+
pythons = 'py3'
6361
oses = 'any'
6462
return pythons, 'none', oses
6563

@@ -72,7 +70,7 @@ def get_tag(self):
7270
packages=packages,
7371
package_data=package_data,
7472
zip_safe=zip_safe,
75-
python_requires='>=2.6',
73+
python_requires='>=3',
7674
setup_requires=['CFFI>=1.0'],
7775
install_requires=['CFFI>=1.0'],
7876
extras_require={'NumPy': ['NumPy']},
@@ -89,7 +87,6 @@ def get_tag(self):
8987
'License :: OSI Approved :: MIT License',
9088
'Operating System :: OS Independent',
9189
'Programming Language :: Python',
92-
'Programming Language :: Python :: 2',
9390
'Programming Language :: Python :: 3',
9491
'Topic :: Multimedia :: Sound/Audio',
9592
],

sounddevice.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -559,14 +559,14 @@ def query_devices(device=None, kind=None):
559559
560560
"""
561561
if kind not in ('input', 'output', None):
562-
raise ValueError('Invalid kind: {0!r}'.format(kind))
562+
raise ValueError('Invalid kind: {!r}'.format(kind))
563563
if device is None and kind is None:
564564
return DeviceList(query_devices(i)
565565
for i in range(_check(_lib.Pa_GetDeviceCount())))
566566
device = _get_device_id(device, kind, raise_on_error=True)
567567
info = _lib.Pa_GetDeviceInfo(device)
568568
if not info:
569-
raise PortAudioError('Error querying device {0}'.format(device))
569+
raise PortAudioError('Error querying device {}'.format(device))
570570
assert info.structVersion == 2
571571
name_bytes = _ffi.string(info.name)
572572
try:
@@ -596,7 +596,7 @@ def query_devices(device=None, kind=None):
596596
}
597597
if kind and device_dict['max_' + kind + '_channels'] < 1:
598598
raise ValueError(
599-
'Not an {0} device: {1!r}'.format(kind, device_dict['name']))
599+
'Not an {} device: {!r}'.format(kind, device_dict['name']))
600600
return device_dict
601601

602602

@@ -642,7 +642,7 @@ def query_hostapis(index=None):
642642
for i in range(_check(_lib.Pa_GetHostApiCount())))
643643
info = _lib.Pa_GetHostApiInfo(index)
644644
if not info:
645-
raise PortAudioError('Error querying host API {0}'.format(index))
645+
raise PortAudioError('Error querying host API {}'.format(index))
646646
assert info.structVersion == 1
647647
return {
648648
'name': _ffi.string(info.name).decode(),
@@ -858,7 +858,7 @@ def callback_ptr(iptr, optr, frames, time, status, _):
858858
_check(_lib.Pa_OpenStream(self._ptr, iparameters, oparameters,
859859
samplerate, blocksize, stream_flags,
860860
callback_ptr, userdata),
861-
'Error opening {0}'.format(self.__class__.__name__))
861+
'Error opening {}'.format(self.__class__.__name__))
862862

863863
# dereference PaStream** --> PaStream*
864864
self._ptr = self._ptr[0]
@@ -1493,7 +1493,7 @@ def write(self, data):
14931493
if data.ndim > 1 and data.shape[1] != channels:
14941494
raise ValueError('Number of channels must match')
14951495
if data.dtype != dtype:
1496-
raise TypeError('dtype mismatch: {0!r} vs {1!r}'.format(
1496+
raise TypeError('dtype mismatch: {!r} vs {!r}'.format(
14971497
data.dtype.name, dtype))
14981498
if not data.flags.c_contiguous:
14991499
raise TypeError('data must be C-contiguous')
@@ -1776,8 +1776,6 @@ def __repr__(self):
17761776
ins=info['max_input_channels'],
17771777
outs=info['max_output_channels'])
17781778
for idx, info in enumerate(self))
1779-
if _sys.version_info.major < 3:
1780-
return text.encode(_sys.stdout.encoding or 'utf-8', 'replace')
17811779
return text
17821780

17831781

@@ -1812,7 +1810,7 @@ def __repr__(self):
18121810
flags = str(self)
18131811
if not flags:
18141812
flags = 'no flags set'
1815-
return '<sounddevice.CallbackFlags: {0}>'.format(flags)
1813+
return '<sounddevice.CallbackFlags: {}>'.format(flags)
18161814

18171815
def __str__(self):
18181816
return ', '.join(name.replace('_', ' ') for name in dir(self)
@@ -1821,8 +1819,6 @@ def __str__(self):
18211819
def __bool__(self):
18221820
return bool(self._flags)
18231821

1824-
__nonzero__ = __bool__ # For Python 2.x
1825-
18261822
def __ior__(self, other):
18271823
if not isinstance(other, CallbackFlags):
18281824
return NotImplemented
@@ -2141,11 +2137,11 @@ class PortAudioError(Exception):
21412137
def __str__(self):
21422138
errormsg = self.args[0] if self.args else ''
21432139
if len(self.args) > 1:
2144-
errormsg = '{0} [PaErrorCode {1}]'.format(errormsg, self.args[1])
2140+
errormsg = '{} [PaErrorCode {}]'.format(errormsg, self.args[1])
21452141
if len(self.args) > 2:
21462142
host_api, hosterror_code, hosterror_text = self.args[2]
21472143
hostname = query_hostapis(host_api)['name']
2148-
errormsg = "{0}: '{1}' [{2} error {3}]".format(
2144+
errormsg = "{}: '{}' [{} error {}]".format(
21492145
errormsg, hosterror_text, hostname, hosterror_code)
21502146

21512147
return errormsg
@@ -2637,7 +2633,7 @@ def _check(err, msg=''):
26372633

26382634
errormsg = _ffi.string(_lib.Pa_GetErrorText(err)).decode()
26392635
if msg:
2640-
errormsg = '{0}: {1}'.format(msg, errormsg)
2636+
errormsg = '{}: {}'.format(msg, errormsg)
26412637

26422638
if err == _lib.paUnanticipatedHostError:
26432639
# (gh82) We grab the host error info here rather than inside
@@ -2669,7 +2665,7 @@ def _get_device_id(id_or_query_string, kind, raise_on_error=False):
26692665
if idev == odev:
26702666
id_or_query_string = idev
26712667
else:
2672-
raise ValueError('Input and output device are different: {0!r}'
2668+
raise ValueError('Input and output device are different: {!r}'
26732669
.format(id_or_query_string))
26742670

26752671
if isinstance(id_or_query_string, int):
@@ -2712,7 +2708,7 @@ def _get_device_id(id_or_query_string, kind, raise_on_error=False):
27122708
if raise_on_error:
27132709
raise ValueError('Multiple ' + kind + ' devices found for ' +
27142710
repr(id_or_query_string) + ':\n' +
2715-
'\n'.join('[{0}] {1}'.format(id, name)
2711+
'\n'.join('[{}] {}'.format(id, name)
27162712
for id, name in matches))
27172713
else:
27182714
return -1

0 commit comments

Comments
 (0)