We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bcc7959 commit 89f124bCopy full SHA for 89f124b
1 file changed
sounddevice.py
@@ -2823,22 +2823,22 @@ def _initialize():
2823
is automatically called with the ``import sounddevice`` statement.
2824
2825
"""
2826
- devnull = None
2827
- old_stderr = 2 # To appease Pyright
+ old_stderr = None
2828
try:
2829
old_stderr = _os.dup(2)
2830
devnull = _os.open(_os.devnull, _os.O_WRONLY)
2831
_os.dup2(devnull, 2)
+ _os.close(devnull)
2832
except OSError:
2833
pass
2834
2835
_check(_lib.Pa_Initialize(), 'Error initializing PortAudio')
2836
global _initialized
2837
_initialized += 1
2838
finally:
2839
- if devnull is not None:
+ if old_stderr is not None:
2840
_os.dup2(old_stderr, 2)
2841
- _os.close(devnull)
+ _os.close(old_stderr)
2842
2843
2844
def _terminate():
0 commit comments