Skip to content

Support Python 3.15 PyCArgObject struct layout changes. - #963

Merged
junkmd merged 2 commits into
py_315_enumfrom
py_315_cargobj
Oct 11, 2026
Merged

junkmd merged 2 commits into
py_315_enumfrom
py_315_cargobj

Conversation

@junkmd

@junkmd junkmd commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

1. Summary

This PR updates the internal PyCArgObject struct layout in comtypes.util to support Python 3.15.
It introduces version-dependent ctypes definitions (tag and size fields) to maintain compatibility with Python 3.15 while preserving backward compatibility for Python 3.8–3.14.

2. Motivation & Background

  • Python 3.15 PyCArgObject Layout Change (See Support Python 3.15 PyCArgObject layout changes in comtypes.util #938):
    • In Python 3.15, CPython altered the internal structure of PyCArgObject in ctypes:
      • tag: changed from c_char to c_char_p
      • size: changed from c_int to c_ssize_t
    • Without an adaptive bridge, low-level offset calculations in comtypes.util fail or cause RuntimeError/memory access issues during import or execution on Python 3.15.
    • Now that the layout is properly bridged, the temporary test-skip logic previously added in test_util.py can be safely removed.

junkmd added 2 commits October 9, 2026 09:14
Remove the temporary logic that skipped tests on Python 3.15.
This logic was previously added to avoid `RuntimeError` during import due to
`PyCArgObject` layout changes.
Update `util` to accommodate changes in the internal `PyCArgObject` structure
introduced in Python 3.15.

The `tag` field was changed from `c_char` to `c_char_p`, and the `size` field
was changed from `c_int` to `c_ssize_t`. This change uses a version-based
bridge to maintain backward compatibility with older Python versions.
@junkmd junkmd added this to the 1.5.0 / Support Python 3.15 milestone Oct 9, 2026
@junkmd
junkmd added this pull request to stack #961 October 9, 2026 14:33
@junkmd
junkmd marked this pull request as draft October 9, 2026 14:34
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (py_315_enum@bd106af). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff               @@
##             py_315_enum     #963   +/-   ##
==============================================
  Coverage               ?   89.16%           
==============================================
  Files                  ?      141           
  Lines                  ?    13793           
  Branches               ?        0           
==============================================
  Hits                   ?    12299           
  Misses                 ?     1494           
  Partials               ?        0           

☔ View full report in Codecov by Harness.
📢 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.

@junkmd
junkmd marked this pull request as ready for review October 11, 2026 00:24
@junkmd
junkmd merged commit b91b041 into main Oct 11, 2026
214 of 378 checks passed
@junkmd
junkmd deleted the py_315_cargobj branch October 11, 2026 02:23
@junkmd junkmd linked an issue Oct 11, 2026 that may be closed by this pull request
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.

Support Python 3.15 PyCArgObject layout changes in comtypes.util

2 participants