Skip to content

Tools - upload.py exception handling fixes #9186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 29, 2025

Conversation

mcspr
Copy link
Collaborator

@mcspr mcspr commented Aug 1, 2024

don't check exc_info() in finally, after except Exception as e: block sys module stops tracking it
https://docs.python.org/3/reference/compound_stmts.html#try
https://docs.python.org/3/library/sys.html#sys.exception

#8603 caused error to appear in the log, but build itself was never stopped properly


edit:

formatting, strict write_flash opts order, atexit & traceback (fe72928)

simplify ordering of write_flash & erase_region arguments
since we always end up in write_flash, prefer to think of it as argument pairs 'addr' + 'path'. actual binaries go first, erase temporaries go last. construct write args beforehand and apply when finishing with the command line.

note that this also allows both commands to appear multiple times
(and also to avoid proxying invalid data or possibly misinterpreting everything as write arguments)

it may be reasonable to try to piggyback on esptool parser, but not sure how that would look for upstream

TODO: update to 4.8.1 which has nicer error messaging

mcspr added 2 commits May 29, 2025 16:25
- don't check exc_info() in `finally`, it only works without `except` with just `try` and `finally`
  see https://docs.python.org/3/reference/compound_stmts.html#try
  after `except Exception as e:` block, `e` is already deleted

- handle a rare case when esptool code does not close 'erase_file'.
  printing paths may cause encoding issues, so just fall through silently
replace temporaries tracking write_flash / erase_region with an append
to a generic write_flash_args list. first are actual files, erased ones
at the end

using atexit for cleanup
@mcspr mcspr force-pushed the upload/destroy-erase-improve branch from 1a1f484 to fe72928 Compare May 29, 2025 15:35
@mcspr mcspr changed the title upload.py - exception handling fixes Tools - upload.py exception handling fixes May 29, 2025
@mcspr mcspr merged commit f5142b8 into esp8266:master May 29, 2025
28 checks passed
@mcspr mcspr deleted the upload/destroy-erase-improve branch May 29, 2025 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant