Skip to content

Commit

Permalink
tools/mpremote: Fix UnboundLocalError in Transport.fs_writefile().
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
glenn20 authored and dpgeorge committed Oct 28, 2024
1 parent 043ba45 commit 9ea8d2a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/mpremote/mpremote/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ def fs_writefile(self, dest, data, chunk_size=256, progress_callback=None):
while data:
chunk = data[:chunk_size]
self.exec("w(" + repr(chunk) + ")")
written += len(chunk)
data = data[len(chunk) :]
if progress_callback:
written += len(chunk)
progress_callback(written, src_size)
self.exec("f.close()")
except TransportExecError as e:
Expand Down

0 comments on commit 9ea8d2a

Please sign in to comment.