diff options
| author | Matthias Geier <Matthias.Geier@gmail.com> | 2022-11-17 20:58:09 +0100 |
|---|---|---|
| committer | Matthias Geier <Matthias.Geier@gmail.com> | 2022-11-17 20:58:09 +0100 |
| commit | 89f124b20f994b29a3f37fe21455604d7579cd49 (patch) | |
| tree | ae5ac5bf2d047dfa9bf008ec765b37ee1ae8e29d | |
| parent | bcc7959bb3ea620fb4963a3f98990ff34cc67f59 (diff) | |
Better file closing?
| -rw-r--r-- | sounddevice.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sounddevice.py b/sounddevice.py index 14653cd..ed72e35 100644 --- a/sounddevice.py +++ b/sounddevice.py @@ -2823,12 +2823,12 @@ def _initialize(): is automatically called with the ``import sounddevice`` statement. """ - devnull = None - old_stderr = 2 # To appease Pyright + old_stderr = None try: old_stderr = _os.dup(2) devnull = _os.open(_os.devnull, _os.O_WRONLY) _os.dup2(devnull, 2) + _os.close(devnull) except OSError: pass try: @@ -2836,9 +2836,9 @@ def _initialize(): global _initialized _initialized += 1 finally: - if devnull is not None: + if old_stderr is not None: _os.dup2(old_stderr, 2) - _os.close(devnull) + _os.close(old_stderr) def _terminate(): |
