Skip to content

Broadly enable finalizers - #11439

Merged
dhalbert merged 4 commits into
adafruit:mainfrom
tannewt:enable_finalizers
Sep 23, 2026
Merged

dhalbert merged 4 commits into
adafruit:mainfrom
tannewt:enable_finalizers

Conversation

@tannewt

@tannewt tannewt commented Sep 21, 2026

Copy link
Copy Markdown
Member

This enables finalizers for many more native CP objects. This allows implementations to use deinit for cleanup reliably.

Older ports may do clean up using bulk resets that require never_reset for special cases. We're moving away from this so allow ports to opt-out of the bulk reset/never reset semantics.

This also narrows the public pin API related to the guarding of reset_all_pins and reliable digitalinout deinit.

First step to finishing #8960

This enables finalizers for many more native CP objects. This allows
implementations to use deinit for cleanup reliably.

Older ports may do clean up using bulk resets that require never_reset
for special cases. We're moving away from this so allow ports to opt-out
of the bulk reset/never reset semantics.

This also narrows the public pin API related to the guarding of
reset_all_pins and reliable digitalinout deinit.

First step to finishing micropython#8960
@tannewt
tannewt marked this pull request as ready for review September 22, 2026 18:59
@tannewt
tannewt requested a review from dhalbert September 22, 2026 18:59

@dhalbert dhalbert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, and plenty here for now.

Did you do some smoke tests on this, like allocating an I2C and then doing ctrl-D and making sure you can do it again?

Comment thread py/circuitpy_mpconfig.mk
@tannewt

tannewt commented Sep 22, 2026

Copy link
Copy Markdown
Member Author

Did you do some smoke tests on this, like allocating an I2C and then doing ctrl-D and making sure you can do it again?

I did not do a smoke test. I only made sure the builds work. I believe this is now equivalent of calling deinit() at the end of VM so I'm not worried about it.

@dhalbert

Copy link
Copy Markdown
Collaborator

I tested an RP2040 Feather, creating a UART, then ctrl-D and creating it on the same pins again. It worked as expected.

@dhalbert
dhalbert merged commit c300b9d into adafruit:main Sep 23, 2026
468 checks passed
tyeth pushed a commit to tyeth/circuitpython that referenced this pull request Oct 3, 2026
Document this in cpydiff and add a test with expected output
for coverage testing.

As discussed in adafruit#11441, the code growth from handling this
case seems to outweigh the benefit of implementing it
properly.

Closes: adafruit#11439

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
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.

2 participants