deprecate should_ignore_error
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Lord · committed by David Lord · parent 9b74a90 · Browse files · 3 files·+27 added−9 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+27 added−9 removed
- other:+27 added−9 removed
Provenance
- Commit
c77a520- Tree
9044680- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent
9b74a90
3 files changed+27 added−9 removed
modified:src/flask/sansio/app.py+9 added-8 removed
920 unmodified lines921 return isinstance(e, BadRequest)922 923 return False924 925- def should_ignore_error(self, error: BaseException | None) -> bool:926- """This is called to figure out if an error should be ignored927- or not as far as the teardown system is concerned. If this928- function returns ``True`` then the teardown handlers will not be929- passed the error.925+ should_ignore_error: None = None926+ """If this method returns ``True``, the error will not be passed to927+ teardown handlers, and the context will not be preserved for928+ debugging.929 931- .. versionadded:: 0.10932- """933- return False930+ .. deprecated:: 3.2931+ Handle errors as needed in teardown handlers instead.932 933+ .. versionadded:: 0.10934+ """935+936 def redirect(self, location: str, code: int = 303) -> BaseResponse:937 """Create a redirect response object.938 939 This is called by :func:`flask.redirect`, and can be called71 unmodified linesmodified:src/flask/app.py+16 added-1 removed
993 unmodified lines994 error handling.995 996 .. versionadded:: 0.7997 """998+ if not self._got_first_request and self.should_ignore_error is not None:999+ import warnings1000+1001+ warnings.warn(1002+ "The 'should_ignore_error' method is deprecated and will"1003+ " be removed in Flask 3.3. Handle errors as needed in"1004+ " teardown handlers instead.",1005+ DeprecationWarning,1006+ stacklevel=1,1007+ )1008+1009 self._got_first_request = True1010 1011 try:1012 request_started.send(self, _async_wrapper=self.ensure_sync)573 unmodified lines1586 finally:1587 if "werkzeug.debug.preserve_context" in environ:1588 environ["werkzeug.debug.preserve_context"](ctx)1589 1579- if error is not None and self.should_ignore_error(error):1590+ if (1591+ error is not None1592+ and self.should_ignore_error is not None1593+ and self.should_ignore_error(error)1594+ ):1595 error = None1596 1597 ctx.pop(error)1598 8 unmodified linesmodified:CHANGES.rst+2 added
12 unmodified lines13 ``AppContext`` as the first parameter, instead of using the proxy objects.14 If subclasses were overriding these methods, the old signature is detected,15 shows a deprecation warning, and will continue to work during the16 deprecation period. :issue:`5815`17+- The ``should_ignore_error`` is deprecated. Handle errors as needed in18+ teardown handlers instead. :issue:`5816`19 - ``template_filter``, ``template_test``, and ``template_global`` decorators20 can be used without parentheses. :issue:`5729`21 - ``redirect`` returns a ``303`` status code by default instead of ``302``.22 This tells the client to always switch to ``GET``, rather than only1629 unmodified lines