Merge branch '2.0.x'
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 · parents ea66c68, d086a51 · Browse files · 4 files·+29 added−20 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+29 added−20 removed
- other:+29 added−20 removed
Provenance
- Commit
6b0c8cd- Tree
35d9e17- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent 1
ea66c68- Parent 2
d086a51
4 files changed+29 added−20 removed
modified:src/flask/cli.py+5 added-4 removed
220 unmodified lines221 __traceback_hide__ = True # noqa: F841222 223 try:224 __import__(module_name)225- except ImportError as e:225+ except ImportError:226 # Reraise the ImportError if it occurred within the imported module.227 # Determine this by checking whether the trace has a depth > 1.228 if sys.exc_info()[2].tb_next:229 raise NoAppException(230- f"While importing {module_name!r}, an ImportError was raised."231- ) from e230+ f"While importing {module_name!r}, an ImportError was"231+ f" raised:\n\n{traceback.format_exc()}"232+ ) from None233 elif raise_if_not_found:233- raise NoAppException(f"Could not import {module_name!r}.") from e234+ raise NoAppException(f"Could not import {module_name!r}.") from None235 else:236 return237 238 module = sys.modules[module_name]717 unmodified linesmodified:src/flask/sessions.py+20 added-8 removed
129 unmodified lines130 131 app = Flask(__name__)132 app.session_interface = MySessionInterface()133 134+ Multiple requests with the same session may be sent and handled135+ concurrently. When implementing a new session interface, consider136+ whether reads or writes to the backing store must be synchronized.137+ There is no guarantee on the order in which the session for each138+ request is opened or saved, it will occur in the order that requests139+ begin and end processing.140+141 .. versionadded:: 0.8142 """143 144 #: :meth:`make_null_session` will look here for the class that should153 unmodified lines298 299 def open_session(300 self, app: "Flask", request: "Request"301 ) -> t.Optional[SessionMixin]:295- """This method has to be implemented and must either return ``None``296- in case the loading failed because of a configuration error or an297- instance of a session object which implements a dictionary like298- interface + the methods and attributes on :class:`SessionMixin`.302+ """This is called at the beginning of each request, after303+ pushing the request context, before matching the URL.304+305+ This must return an object which implements a dictionary-like306+ interface as well as the :class:`SessionMixin` interface.307+308+ This will return ``None`` to indicate that loading failed in309+ some way that is not immediately an error. The request310+ context will fall back to using :meth:`make_null_session`311+ in this case.312 """313 raise NotImplementedError()314 315 def save_session(316 self, app: "Flask", session: SessionMixin, response: "Response"317 ) -> None:305- """This is called for actual sessions returned by :meth:`open_session`306- at the end of the request. This is still called during a request307- context so if you absolutely need access to the request you can do308- that.318+ """This is called at the end of each request, after generating319+ a response, before removing the request context. It is skipped320+ if :meth:`is_null_session` returns ``True``.321 """322 raise NotImplementedError()323 324 92 unmodified linesmodified:src/flask/typing.py+1 added-8 removed
44 unmodified lines45 TemplateGlobalCallable = t.Callable[..., t.Any]46 TemplateTestCallable = t.Callable[..., bool]47 URLDefaultCallable = t.Callable[[str, dict], None]48 URLValuePreprocessorCallable = t.Callable[[t.Optional[str], t.Optional[dict]], None]49-50-51-if t.TYPE_CHECKING:52- import typing_extensions as te53-54- class ErrorHandlerCallable(te.Protocol[GenericException]):55- def __call__(self, error: GenericException) -> ResponseReturnValue:56- ...49+ErrorHandlerCallable = t.Callable[[GenericException], ResponseReturnValue]modified:CHANGES.rst+3 added
37 unmodified lines38 - The test client's ``as_tuple`` parameter is deprecated and will be39 removed in Werkzeug 2.1. It is now also deprecated in Flask, to be40 removed in Flask 2.1, while remaining compatible with both in41 2.0.x. Use ``response.request.environ`` instead. :pr:`4341`42+- Fix type annotation for ``errorhandler`` decorator. :issue:`4295`43+- Revert a change to the CLI that caused it to hide ``ImportError``44+ tracebacks when importing the application. :issue:`4307`45 46 47 Version 2.0.248 -------------1180 unmodified lines