Skip to content

Commit 9ea8d2a

Browse files
glenn20dpgeorge
authored andcommitted
tools/mpremote: Fix UnboundLocalError in Transport.fs_writefile().
The variable `written` was being used before it was defined in the `fs_writefile()` method of the Transport class. This was causing an `UnboundLocalError` to be raised when the `progress_callback` was not provided. Fixes issue micropython#16084. Signed-off-by: Glenn Moloney <[email protected]>
1 parent 043ba45 commit 9ea8d2a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/mpremote/mpremote/transport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ def fs_writefile(self, dest, data, chunk_size=256, progress_callback=None):
151151
while data:
152152
chunk = data[:chunk_size]
153153
self.exec("w(" + repr(chunk) + ")")
154-
written += len(chunk)
155154
data = data[len(chunk) :]
156155
if progress_callback:
156+
written += len(chunk)
157157
progress_callback(written, src_size)
158158
self.exec("f.close()")
159159
except TransportExecError as e:

0 commit comments

Comments
 (0)