Skip to content
Snippets Groups Projects
Commit a2703649 authored by Andrew Leech's avatar Andrew Leech Committed by Damien George
Browse files

tools/pydfu: Workaround stdio flush error on Windows with Python 3.6.

There appears to be an issue on Windows with CPython >= 3.6,
sys.stdout.flush() raises an exception:

    OSError: [WinError 87] The parameter is incorrect

It works fine to just catch and ignore the error on the flush line.  Tested
on Windows 10 x64 1803 (Build 17134.228), Python 3.6.4 amd64.
parent cb3c66e7
Branches
No related tags found
No related merge requests found
...@@ -482,7 +482,10 @@ def cli_progress(addr, offset, size): ...@@ -482,7 +482,10 @@ def cli_progress(addr, offset, size):
print("\r0x{:08x} {:7d} [{}{}] {:3d}% " print("\r0x{:08x} {:7d} [{}{}] {:3d}% "
.format(addr, size, '=' * done, ' ' * (width - done), .format(addr, size, '=' * done, ' ' * (width - done),
offset * 100 // size), end="") offset * 100 // size), end="")
try:
sys.stdout.flush() sys.stdout.flush()
except OSError:
pass # Ignore Windows CLI "WinError 87" on Python 3.6
if offset == size: if offset == size:
print("") print("")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment