◐ Shell
clean mode source ↗

[WIP] bpo-29672: Save and restore module warning registries in catch_warnings by segevfiner · Pull Request #8232 · python/cpython

Conversation

@segevfiner

This avoids catch_warnings wiping out all module warning registries due to calling _filters_mutated. Which causes all warnings recorded in those registries to be shown again.

I'm not sure if this is the right approach for this, so I'm submitting this incomplete in order to garner feedback, and for answers to the questions in TODO below.

TODO

  • Should onceregistry be saved and restored too?
  • A better test? I'm not sure how to test this better since catch_warnings is used for the warnings tests themselves.
  • Consider the order that things are done in catch_warnings.__enter__ and catch_warnings.__exit__, to cause the least disturbance due to threads (It's not thread safe anyhow...)
  • Documentation & NEWS.d obviously

https://bugs.python.org/issue29672

This avoids catch_warnings wiping out all module warning registries due
to calling _filters_mutated. Which causes all warnings recorded in those
registries to be shown again.

gerritholl added a commit to FIDUCEO/FCDR_HIRS that referenced this pull request

Oct 12, 2018

ZackerySpytz

@patnr

…nings-registries-restore

@Czaki Czaki mentioned this pull request

Oct 27, 2023

@anmyachev

Hi @segevfiner do you plan to continue working on this pull request? Or are you waiting for a review?

I ask because I also encountered this problem and I wonder if it can be solved in the near future.

@segevfiner

Hi @segevfiner do you plan to continue working on this pull request? Or are you waiting for a review?

I ask because I also encountered this problem and I wonder if it can be solved in the near future.

It was waiting for a full review since a long time ago (2018...), and seems to have gone stale quite a bit by now. I can try to resolve the conflicts, but even then, I'm not sure any core maintainer will review this

@rhshadrach

but even then, I'm not sure any core maintainer will review this

I imagine this has a wide impact, we've gotten numerous issues raised in pandas. As the linked issue points out, one can hit this from the standard library too. I don't understand why it wouldn't be reviewed, but maybe there is some way we can drum up support?

@github-actions

This PR is stale because it has been open for 30 days with no activity.

Labels

stale

Stale PR or inactive for long period of time.