diff -r 7258d36204be -r 5c09d70e9290 src/eric7/CodeFormatting/IsortFormattingDialog.py --- a/src/eric7/CodeFormatting/IsortFormattingDialog.py Sat Nov 05 13:00:17 2022 +0100 +++ b/src/eric7/CodeFormatting/IsortFormattingDialog.py Sat Nov 05 13:01:29 2022 +0100 @@ -7,9 +7,11 @@ Module implementing a dialog showing the isort code formatting progress and the results. """ +import contextlib import copy import io import multiprocessing +import os import pathlib from dataclasses import dataclass @@ -30,7 +32,6 @@ from .FormattingDiffWidget import FormattingDiffWidget from .IsortFormattingAction import IsortFormattingAction -from .IsortUtilities import suppressStderr from .Ui_IsortFormattingDialog import Ui_IsortFormattingDialog @@ -550,8 +551,13 @@ @rtype IsortResult """ diffIO = io.StringIO() if withDiff else False - with suppressStderr(): - ok = check_file(filename, show_diff=diffIO, config=isortConfig) + with open(os.devnull, "w") as devnull: + with contextlib.redirect_stderr(devnull): + ok = check_file( + filename, + show_diff=diffIO, + config=isortConfig, + ) if withDiff: data = "" if ok else diffIO.getvalue() diffIO.close() @@ -574,14 +580,15 @@ @return result object @rtype IsortResult """ - with suppressStderr(): - ok = sort_file( - filename, - config=isortConfig, - ask_to_apply=False, - write_to_stdout=False, - show_diff=False, - ) + with open(os.devnull, "w") as devnull: + with contextlib.redirect_stderr(devnull): + ok = sort_file( + filename, + config=isortConfig, + ask_to_apply=False, + write_to_stdout=False, + show_diff=False, + ) status = "changed" if ok else "unchanged"