Skip to content

py/objcode: Remove co_lnotab from v2 preview. #17639

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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.

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).

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.

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
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
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy