Skip to content

gh-122255: Synchronize warnings in C and Python implementations of the warnings module - #122824

Merged
serhiy-storchaka merged 6 commits into
python:mainfrom
serhiy-storchaka:spec-loader-warnings
Nov 14, 2025
Merged

serhiy-storchaka merged 6 commits into
python:mainfrom
serhiy-storchaka:spec-loader-warnings

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Aug 8, 2024 •

Copy link
Copy Markdown
Member

In the linecache module and in the Python implementation of the warnings module, a DeprecationWarning is issued when m.__loader__ differs from m.__spec__.loader (like in the C implementation of the warnings module).

… of the warnings module

In the linecache module and in the Python implementation of the
warnings module, a DeprecationWarning is issued when
m.__loader__ differs from m.__spec__.loader (like in the C
implementation of the warnings module).
Comment thread Lib/linecache.py Resolved
@serhiy-storchaka

serhiy-storchaka commented Sep 24, 2024 •

Copy link
Copy Markdown
Member Author

Failed tests show that we may reconsider this deprecation.

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. I just left minor comments.

Comment thread Lib/linecache.py
DeprecationWarning)
return loader

assert spec_loader is not None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This assertion looks redundant.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There is such assertion in _bless_my_loader() in Lib/importlib/_bootstrap_external.py. This function is its copy with minimal necessary changes.

@brettcannon
brettcannon removed their request for review September 19, 2025 10:49
@serhiy-storchaka
serhiy-storchaka merged commit 8deaa93 into python:main Nov 14, 2025
@serhiy-storchaka
serhiy-storchaka deleted the spec-loader-warnings branch November 14, 2025 14:49
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
… of the warnings module (pythonGH-122824)

In the linecache module and in the Python implementation of the
warnings module, a DeprecationWarning is issued when
m.__loader__ differs from m.__spec__.loader (like in the C
implementation of the warnings module).
pytorchmergebot pushed a commit to pytorch/pytorch that referenced this pull request Jun 18, 2026
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants