Skip to content
Myr

update error message for after_this_request and copy_current_request_context

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 633449a · Browse files · 2 files+9 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+9 added−8 removed

  • other:+9 added−8 removed

2 files+9 added−8 removed

modified:src/flask/ctx.py+8 added-7 removed
129 unmodified lines
130131 .. versionadded:: 0.9132 """133 top = _request_ctx_stack.top134135 if top is None:136 raise RuntimeError(136 "This decorator can only be used at local scopes "137 "when a request context is on the stack. For instance within "138 "view functions."137 "This decorator can only be used when a request context is"138 " active, such as within a view function."139 )140 top._after_request_functions.append(f)140141 top._after_request_functions.append(f)142 return f143144145def copy_current_request_context(f: t.Callable) -> t.Callable:
20 unmodified lines
166167 .. versionadded:: 0.10168 """169 top = _request_ctx_stack.top170171 if top is None:172 raise RuntimeError(172 "This decorator can only be used at local scopes "173 "when a request context is on the stack. For instance within "174 "view functions."173 "This decorator can only be used when a request context is"174 " active, such as within a view function."175 )176177 reqctx = top.copy()178179 def wrapper(*args, **kwargs):180 with reqctx:
309 unmodified lines
modified:CHANGES.rst+1 added-1 removed
13 unmodified lines
14 tracebacks when importing the application. :issue:`4307`15- ``app.json_encoder`` and ``json_decoder`` are only passed to16 ``dumps`` and ``loads`` if they have custom behavior. This improves17 performance, mainly on PyPy. :issue:`4349`18- Fix error message for ``after_this_request`` when it used outside18- Clearer error message when ``after_this_request`` is used outside a19 request context. :issue:`4333`202122Version 2.0.2
1181 unmodified lines