Skip to content

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

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 3 commits into
base: main
Choose a base branch
from

Conversation

serhiy-storchaka
Copy link
Member

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

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).
@@ -0,0 +1,4 @@
In the :mod:`linecache` module and in the Python implementation of the
:mod:`warnings` module, a ``DeprecationWarning`` is issued when
``m.__loader__`` differs from ``m.__spec__.loader`` (like in the C
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
``m.__loader__`` differs from ``m.__spec__.loader`` (like in the C
``mod.__loader__`` differs from ``mod.__spec__.loader`` (like in the C

return False

if module_globals is not None and not isinstance(module_globals, dict):
raise TypeError(f'module_globals must be a dict, not {type(module_globals).__name__}')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
raise TypeError(f'module_globals must be a dict, not {type(module_globals).__name__}')
raise TypeError(f'module_globals must be a dict, not {type(module_globals).__qualname__}')

@serhiy-storchaka
Copy link
Member Author

serhiy-storchaka commented Sep 24, 2024

Failed tests show that we may reconsider this deprecation.

Copy link
Member

@vstinner vstinner left a comment

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.

DeprecationWarning)
return loader

assert spec_loader is not None
Copy link
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.

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.

2 participants