summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Leech <andrew.leech@planetinnovation.com.au>2018-09-12 16:42:06 +1000
committerDamien George <damien.p.george@gmail.com>2018-09-21 11:57:24 +1000
commita2703649ea4455fe11388e24fad68a66441daf68 (patch)
tree7119f8a1f8bc58fd79d3393822f41311adc29d36
parentcb3c66e79358f03367d0b4e5d2b6ec649ac29733 (diff)
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.
-rwxr-xr-xtools/pydfu.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/pydfu.py b/tools/pydfu.py
index c6b6802c8..e7f4ab178 100755
--- a/tools/pydfu.py
+++ b/tools/pydfu.py
@@ -482,7 +482,10 @@ def cli_progress(addr, offset, size):
print("\r0x{:08x} {:7d} [{}{}] {:3d}% "
.format(addr, size, '=' * done, ' ' * (width - done),
offset * 100 // size), end="")
- sys.stdout.flush()
+ try:
+ sys.stdout.flush()
+ except OSError:
+ pass # Ignore Windows CLI "WinError 87" on Python 3.6
if offset == size:
print("")