Skip to content
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

ENH: Do not overwrite global warning formatter #3287

Closed
connortann opened this issue Sep 27, 2023 · 1 comment · Fixed by #3514
Closed

ENH: Do not overwrite global warning formatter #3287

connortann opened this issue Sep 27, 2023 · 1 comment · Fixed by #3514
Labels
enhancement Indicates new feature requests
Milestone

Comments

@connortann
Copy link
Collaborator

connortann commented Sep 27, 2023

The global warnings formatter is overwritten here:

warnings.formatwarning = lambda msg, *args, **kwargs: str(msg) + '\n' # ignore everything except the message

This pattern of overwriting the builtin implementation is actually recommended in the docs of the builtin warnings module. However, this kind of import-time side-effect seems inappropriate for a package, as it will interfere with other packages' use of warnings.

A similar case caused issues in the pypdf2 package: py-pdf/pypdf#67

@connortann connortann added the enhancement Indicates new feature requests label Sep 27, 2023
@connortann connortann added this to the 0.44.0 milestone Sep 29, 2023
@seminumber
Copy link

This decision of updating warnings package was very poor and it really hurt our development procedure. Our production code relies on many packages along and use heavily on warnings and all of the sudden, we got this issue and nobody could figure that out for about a year until we finally decide to delve into the issue. Our codebase is large and we cannot identify which makes this issue until today :(. I logged in to report this issue but it has already been reported. This issue should be more of a bug than an enhancement in my view.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates new feature requests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants