Closed Torxed closed 2 months ago
this is a common problem with python itself due to some "interesting" choices in the Io implementation
try for instance with a print loop
Can you elaborate on "try a print loop"?
I feel this is a flake8
cli tooling issue, where it's missing something along the lines of:
try:
sys.stdout.buffer.write(...)
except BrokenPipeError:
exit()
@Torxed printing to a tty (or pty) is not the only use-case of Flake8. It's possible for someone to print to both stdout and to a file simultaneously with CLI flags. If we simply exit when something goes wrong (and do so silently) then we truncate what we write to the file without notice. If instead we just ignore every BrokenPipeError so writing to the file succeeds, what do we do then? Exit with non-zero somehow?
You're proposing a simple solution to something which fits your simplistic mental model which happens to be wrong.
The better solution is to fail loudly so the user knows that something went wrong unexpectedly. The point Anthony is making above is that Python has chosen to implement things this way. Other languages don't break in this particular manner, so fundamentally this is a flaw in Python.
how did you install flake8?
unmodified output of
flake8 --bug-report
describe the problem
what I expected to happen
Flake8 handling
sys.stdout
closure gracefully.sample code
Any code will work, and will generate:
commands ran