forked from orbit-oss/flask
deprecate should_ignore_error (#5899)
This commit is contained in:
commit
4b8bde97d4
3 changed files with 27 additions and 9 deletions
|
|
@ -14,6 +14,8 @@ Unreleased
|
||||||
If subclasses were overriding these methods, the old signature is detected,
|
If subclasses were overriding these methods, the old signature is detected,
|
||||||
shows a deprecation warning, and will continue to work during the
|
shows a deprecation warning, and will continue to work during the
|
||||||
deprecation period. :issue:`5815`
|
deprecation period. :issue:`5815`
|
||||||
|
- The ``should_ignore_error`` is deprecated. Handle errors as needed in
|
||||||
|
teardown handlers instead. :issue:`5816`
|
||||||
- ``template_filter``, ``template_test``, and ``template_global`` decorators
|
- ``template_filter``, ``template_test``, and ``template_global`` decorators
|
||||||
can be used without parentheses. :issue:`5729`
|
can be used without parentheses. :issue:`5729`
|
||||||
- ``redirect`` returns a ``303`` status code by default instead of ``302``.
|
- ``redirect`` returns a ``303`` status code by default instead of ``302``.
|
||||||
|
|
|
||||||
|
|
@ -995,6 +995,17 @@ class Flask(App):
|
||||||
|
|
||||||
.. versionadded:: 0.7
|
.. versionadded:: 0.7
|
||||||
"""
|
"""
|
||||||
|
if not self._got_first_request and self.should_ignore_error is not None:
|
||||||
|
import warnings
|
||||||
|
|
||||||
|
warnings.warn(
|
||||||
|
"The 'should_ignore_error' method is deprecated and will"
|
||||||
|
" be removed in Flask 3.3. Handle errors as needed in"
|
||||||
|
" teardown handlers instead.",
|
||||||
|
DeprecationWarning,
|
||||||
|
stacklevel=1,
|
||||||
|
)
|
||||||
|
|
||||||
self._got_first_request = True
|
self._got_first_request = True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -1576,7 +1587,11 @@ class Flask(App):
|
||||||
if "werkzeug.debug.preserve_context" in environ:
|
if "werkzeug.debug.preserve_context" in environ:
|
||||||
environ["werkzeug.debug.preserve_context"](ctx)
|
environ["werkzeug.debug.preserve_context"](ctx)
|
||||||
|
|
||||||
if error is not None and self.should_ignore_error(error):
|
if (
|
||||||
|
error is not None
|
||||||
|
and self.should_ignore_error is not None
|
||||||
|
and self.should_ignore_error(error)
|
||||||
|
):
|
||||||
error = None
|
error = None
|
||||||
|
|
||||||
ctx.pop(error)
|
ctx.pop(error)
|
||||||
|
|
|
||||||
|
|
@ -922,15 +922,16 @@ class App(Scaffold):
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def should_ignore_error(self, error: BaseException | None) -> bool:
|
should_ignore_error: None = None
|
||||||
"""This is called to figure out if an error should be ignored
|
"""If this method returns ``True``, the error will not be passed to
|
||||||
or not as far as the teardown system is concerned. If this
|
teardown handlers, and the context will not be preserved for
|
||||||
function returns ``True`` then the teardown handlers will not be
|
debugging.
|
||||||
passed the error.
|
|
||||||
|
.. deprecated:: 3.2
|
||||||
|
Handle errors as needed in teardown handlers instead.
|
||||||
|
|
||||||
.. versionadded:: 0.10
|
.. versionadded:: 0.10
|
||||||
"""
|
"""
|
||||||
return False
|
|
||||||
|
|
||||||
def redirect(self, location: str, code: int = 303) -> BaseResponse:
|
def redirect(self, location: str, code: int = 303) -> BaseResponse:
|
||||||
"""Create a redirect response object.
|
"""Create a redirect response object.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue