From ece8f15edaa6efcc617cc91508ac3ba6227a6254 Mon Sep 17 00:00:00 2001 From: cclauss Date: Sat, 6 Jan 2018 07:10:06 +0100 Subject: Use sys.stderr_backup in both save and restore There is no __sys.stderr_backup__ defined in the [Python sys] module. __save_stderr()__ adds a variable by that name which is a bit unconventional but it does work. This PR changes __restore_stderr()__ to read that data from the same variable. Without this change, __restore_stderr()__ will probably raise a NameError at runtime because __stderr_backup__ is an undefined name. flake8 testing of https://github.com/lexelby/inkstitch on Python 2.7.14 $ __flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics__ ``` ./embroider_params.py:748:18: F821 undefined name 'stderr_backup' sys.stderr = stderr_backup ^ ``` --- embroider_params.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'embroider_params.py') diff --git a/embroider_params.py b/embroider_params.py index b0915ff2..7cba8fb0 100644 --- a/embroider_params.py +++ b/embroider_params.py @@ -745,7 +745,7 @@ def save_stderr(): def restore_stderr(): os.dup2(sys.stderr_dup, 2) sys.stderr_backup.write(sys.stderr.getvalue()) - sys.stderr = stderr_backup + sys.stderr = sys.stderr_backup # end of class MyFrame -- cgit v1.2.3