Skip to content

Fix a PyLint 2.13.7 error

Michał Kępień requested to merge 3297-fix-a-pylint-2.13.7-error into main

PyLint 2.13.7 reports the following error:

bin/tests/system/doth/conftest.py:34:28: E0601: Using variable 'stderr' before assignment (used-before-assignment)

The reason the current code has not caused problems before is that invoking gnutls-cli with just the --logfile=/dev/null argument causes it to always return with a non-zero exit code, either due to the option not being supported or due to the hostname argument not being provided. In other words, the 'except' branch has always been taken. PyLint is obviously right on a syntactical level, though, so assign a default value to the 'stderr' variable in the 'try' branch in order to address the problem.

While this issue was investigated, it was also noticed that subprocess.check_output() is incorrectly used as a context manager: Popen objects are context managers, but subprocess.check_output() is not. Fix by dropping the relevant 'with' statement.

Closes #3297 (closed)

Merge request reports