Skip to content

[Python] Set __spec__ attribute and not __cached__ for ROOT facade#21790

Merged
guitargeek merged 1 commit intoroot-project:masterfrom
guitargeek:issue-21787
Apr 7, 2026
Merged

[Python] Set __spec__ attribute and not __cached__ for ROOT facade#21790
guitargeek merged 1 commit intoroot-project:masterfrom
guitargeek:issue-21787

Conversation

@guitargeek
Copy link
Copy Markdown
Contributor

@guitargeek guitargeek commented Apr 3, 2026

The Python documentation [1] says:

It is strongly recommended that you use module.spec.cached instead
of module.cached.

So this commit suggests to transfer the full __spec__ attribute from the ROOT module to the facade, instead of __cached__.

This also avoids errors when importing ROOT with Python 3.15, where __cached__ will cease to be set or taken into consideration by the import system or standard library.

Closes #21787.

[1] https://docs.python.org/3/reference/datamodel.html#module.__cached__

Thanks @ellert for reporting the problem!

To be backported to 6.36 and 6.38.

The Python documentation [1] says:

> It is strongly recommended that you use module.__spec__.cached instead
  of module.__cached__.

So this commit suggests to transfer the full `__spec__` attribute from
the ROOT module to the facade, instead of `__cached__`.

This also avoids errors when importing ROOT with Python 3.15, where
`__cached__` will cease to be set or taken into consideration by the
import system or standard library.

Closes root-project#21787.

[1] https://docs.python.org/3/reference/datamodel.html#module.__cached__
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

Test Results

    22 files      22 suites   3d 6h 23m 13s ⏱️
 3 833 tests  3 832 ✅  1 💤 0 ❌
76 576 runs  76 558 ✅ 18 💤 0 ❌

Results for commit 4171724.

@guitargeek guitargeek requested a review from aaronj0 April 7, 2026 12:06
Copy link
Copy Markdown
Contributor

@aaronj0 aaronj0 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@guitargeek guitargeek merged commit 8374d02 into root-project:master Apr 7, 2026
31 of 33 checks passed
@guitargeek guitargeek deleted the issue-21787 branch April 7, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ROOT and Python 3.15

2 participants