8000 py/objcode: Remove co_lnotab from v2 preview. by AJMansfield · Pull Request #17639 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@AJMansfield
Copy link
Contributor
@AJMansfield AJMansfield commented Jul 8, 2025

Summary

Starting in CPython 3.12, accessing the co_lnotab attribute on code objects results in a deprecation message; and in theory, attempting to use it will be an AttributeError in CPython 3.15. Likewise, the corresponding provision in PEP-626 states that "the co_lnotab attribute will be deprecated in 3.10 and removed in 3.12."

Once #16989 is merged (to implement the co_lines method that co_lnotab is being removed in favor of), Micropython should follow suit to deprecate and remove co_lnotab from our v2 previews (and eventually, the Micropython 2.0 release).

This PR does this, adding MICROPY_PREVIEW_VERSION_2 macro gates to the co_lnotab attr entry and corresponding function implementation.

Testing

This PR adds a new set of automated test cases to validate the v2 removal and pre-v2 non-removal of co_lnotab, replacing a test from #16989 that only applies to pre-v2.
I've run these tests and verified correct behavior on both v2-preview and non-preview settrace builds of the unix port.

Trade-offs and Alternatives

Aside from the expected compatibility break with v2 preview, there are no downsides to this. This is a strict improvement to code size on settrace builds, and should have no effect on standard builds.

@AJMansfield AJMansfield force-pushed the deprecate_co_lnotab branch 2 times, most recently from bc273ac to aaeb97a Compare July 8, 2025 16:15
@AJMansfield
Copy link
Contributor Author
AJMansfield commented Jul 8, 2025

The intended commits here are only the last two:

  • tests/basics/fun_code_lnotab: Test removal of co_lnotab in v2.
  • py/objcode: Remove co_lnotab from v2 preview.

Once #16989 is merged I'll rebase this so it doesn't include the commits from it that this PR depends on.

@codecov
Copy link
codecov bot commented Jul 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.41%. Comparing base (17fbc5a) to head (ddf2c3a).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #17639      +/-   ##
==========================================
- Coverage   98.44%   98.41%   -0.04%     
==========================================
  Files         171      171              
  Lines       22208    22210       +2     
==========================================
- Hits        21863    21857       -6     
- Misses        345      353       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
github-actions bot commented Jul 8, 2025

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@AJMansfield AJMansfield force-pushed the deprecate_co_lnotab branch from aaeb97a to 732a7f4 Compare July 8, 2025 16:53
@dpgeorge dpgeorge added the py-core Relates to py/ directory in source label Jul 9, 2025
@dpgeorge
Copy link
Member
dpgeorge commented Jul 9, 2025

This can now be rebased.

@AJMansfield AJMansfield force-pushed the deprecate_co_lnotab branch from 732a7f4 to 77cd526 Compare July 9, 2025 01:52
@AJMansfield AJMansfield force-pushed the deprecate_co_lnotab branch from 77cd526 to baf93dd Compare July 18, 2025 14:54
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
@AJMansfield AJMansfield force-pushed the deprecate_co_lnotab branch from baf93dd to ddf2c3a Compare July 18, 2025 14:59
@dpgeorge dpgeorge merged commit ddf2c3a into micropython:master Jul 20, 2025
66 of 69 checks passed
AJMansfield added a commit to AJMansfield/micropython that referenced this pull request Nov 2, 2025
This field exists to cache the lnotab field removed from v2 in micropython#17639 by
ddf2c3a, and is now unused.

Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
dpgeorge pushed a commit to AJMansfield/micropython that referenced this pull request Nov 3, 2025
This field exists to cache the lnotab field removed from v2 in micropython#17639 by
ddf2c3a, and is now unused.

Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

py-core Relates to py/ directory in source

Projects < 44BD /h3>
None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0