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

Fix: reduce number of deprecation warnings #1135

Merged
merged 1 commit into from May 6, 2023

Conversation

dairiki
Copy link
Contributor

@dairiki dairiki commented Apr 21, 2023

The @lektor.utils.deprecated decorator introduced in #1113 uses the warnings.catch_warnings context manager to suppress deprecation warnings generated within the body of deprecated functions.

As it turns out, there is (arguably) a bug in Python's warnings module, such that every use of warnings.catch_warnings essentially erases all record of which warnings have been displayed.

This breaks the "default" setting of the warnings filter which is supposed to ensure that each warning is only displayed once per (module, line).

So here, we disuse catch_warnings.

Description of Changes

  • Added unit test(s) covering the changes (if testable)

@dairiki dairiki force-pushed the fix.too-many-deprecation-warnings branch from 981f05a to 1bc82bc Compare April 24, 2023 00:39
@dairiki dairiki added this to the 3.4 milestone Apr 24, 2023
@dairiki dairiki force-pushed the fix.too-many-deprecation-warnings branch from 1bc82bc to 415a7a9 Compare May 6, 2023 00:04
There is (arguably) a bug in Python's warnings module, such that every
use of warnings.catch_warnings erases all memory of which warnings
have been displayed.

This breaks the "default" setting of the warnings filter which is
supposed to ensure that each warning is only displayed once per
(module, line).

So here, we disuse catch_warnings.

See https://bugs.python.org/issue29672
@dairiki dairiki force-pushed the fix.too-many-deprecation-warnings branch from 415a7a9 to 5d9c24c Compare May 6, 2023 00:47
@dairiki dairiki merged commit 720fe95 into lektor:master May 6, 2023
15 checks passed
@dairiki dairiki deleted the fix.too-many-deprecation-warnings branch May 6, 2023 01:10
dairiki added a commit to dairiki/lektor that referenced this pull request Sep 11, 2023
There is (arguably) a bug in Python's warnings module, such that every
use of warnings.catch_warnings erases all memory of which warnings
have been displayed.

This breaks the "default" setting of the warnings filter which is
supposed to ensure that each warning is only displayed once per
(module, line).

So here, we disuse catch_warnings.

See https://bugs.python.org/issue29672
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant