Skip to content

#12645 Fix Python 3.15 compatibility issues in trial - #12602

Open
frenzymadness wants to merge 1 commit into
twisted:trunkfrom
frenzymadness:py315
Open

frenzymadness wants to merge 1 commit into
twisted:trunkfrom
frenzymadness:py315

Conversation

@frenzymadness

@frenzymadness frenzymadness commented Apr 1, 2026 •

Copy link
Copy Markdown

Fixes #12645

  • Replace deprecated SourceFileLoader.load_module() with exec_module()
  • Add addSubTest() method to _AdaptedReporter for Python 3.15 doctest support
  • Update test expectations for Python 3.15 doctest changes:
    • Different success/failure counts
    • Changed error output format

Some of the changes are required for Python 3.15 compatibility because: python/cpython#134890

- Replace deprecated SourceFileLoader.load_module() with exec_module()
- Add addSubTest() method to _AdaptedReporter for Python 3.15 doctest support
- Update test expectations for Python 3.15 doctest changes:
  - Different success/failure counts
  - Changed error output format
@codspeed

codspeed Bot commented Apr 1, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 36 untouched benchmarks


Comparing frenzymadness:py315 (3962d15) with trunk (3d84863)

Open in CodSpeed

@adiroiban

Copy link
Copy Markdown
Member

Thanks for the PR.
We need to also enable some tests on Python 3.15

Unfortunatelly, there is still work left to add python 3.14 compatibility

The high level task for 3.14 is here

#12430

I have created an issue to track Python 3.15 compatibility at #12603
For 3.15 we need to enable automated tests... on all our supported platforms. Not sure if this can be done in a single task... or it requires multiple tasks, like 3.14

@glyph in GitHub Issues we can "pin" / highlight up to 3 issues. I have pinned the issue for 3.14 and 3.15 as I think that the most important task for Twisted right now is to keep it available on latest Python versions

Freel free to un-pin them or add another one the list of pinned issues

@adiroiban adiroiban changed the title Fix Python 3.15 compatibility issues #12645 Fix Python 3.15 compatibility issues in trial May 12, 2026
@adiroiban

Copy link
Copy Markdown
Member

Just an update.

I have created a separate ticket to track the errors of twisted.trial with Python 3.15

I am working on #12643 to get Python 3.15 executed as part of our PR tests...

Once that is done, we should be able to test, review and merge this PR.

Thanks again

Comment on lines +763 to +764
loader = SourceFileLoader(name, fileName)
spec = importlib.util.spec_from_loader(name, loader)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if we can re-use _importFromFile here

Comment on lines +766 to +767
sys.modules[name] = module
spec.loader.exec_module(module)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Possible regression here, if execution of the module fails, then we probably don't want to leave it in sys.modules.

@glyph

glyph commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

This seems to be missing the CI configuration change to make the tests actually run on 3.15, which explains the coverage gaps?

@glyph

glyph commented Oct 4, 2026

Copy link
Copy Markdown
Member

@frenzymadness since this PR predates our new PR template and AI policy, can you just confirm that this PR is not LLM output? It doesn't look like it to me but it would be good to have affirmative confirmation.

@frenzymadness

Copy link
Copy Markdown
Author

The code here is not an output of LLM. I kinda lost context since I created it, so I'd appreciate it if you could take it and finish it. If you don't have time or don't want to, say so, and I'll add it to my to-do with higher priority.

@adiroiban

Copy link
Copy Markdown
Member

Thanks for the PR. We now have tests running on 3.15 . I am happy to review fixes for trial :)

@glyph

glyph commented Oct 6, 2026

Copy link
Copy Markdown
Member

The code here is not an output of LLM. I kinda lost context since I created it, so I'd appreciate it if you could take it and finish it. If you don't have time or don't want to, say so, and I'll add it to my to-do with higher priority.

Thanks for the reply. We are happy to run with it, thanks for letting us know the status clearly. And thanks for contributing it!

This branch has not been deployed

No deployments
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.

Add support for Python 3.15 in trial

4 participants