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

Deprecate debug argument #3381

Merged
merged 4 commits into from
Nov 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/3381.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Depreacte explicit debug argument. Use asyncio debug mode instead.
9 changes: 8 additions & 1 deletion aiohttp/web_app.py
Original file line number Diff line number Diff line change
@@ -82,6 +82,10 @@ def __init__(self, *,
warnings.warn("loop argument is deprecated", DeprecationWarning,
stacklevel=2)

if debug is not ...:
warnings.warn("debug argument is deprecated",
DeprecationWarning,
stacklevel=2)
self._debug = debug
self._router = router # type: UrlDispatcher
self._loop = loop
@@ -226,6 +230,9 @@ def freeze(self) -> None:

@property
def debug(self) -> bool:
warnings.warn("debug property is deprecated",
DeprecationWarning,
stacklevel=2)
return self._debug

def _reg_subapp_signals(self, subapp: 'Application') -> None:
@@ -326,7 +333,7 @@ def _make_handler(self, *,
self._set_loop(loop)
self.freeze()

kwargs['debug'] = self.debug
kwargs['debug'] = self._debug
kwargs['access_log_class'] = access_log_class
if self._handler_args:
for k, v in self._handler_args.items():
8 changes: 8 additions & 0 deletions docs/web_reference.rst
Original file line number Diff line number Diff line change
@@ -1281,6 +1281,10 @@ duplicated like one using :meth:`Application.copy`.

:param debug: Switches debug mode.

.. deprecated:: 3.5

Use asyncio :ref:`asyncio-debug-mode` instead.

.. attribute:: router

Read-only property that returns *router instance*.
@@ -1299,6 +1303,10 @@ duplicated like one using :meth:`Application.copy`.

Boolean value indicating whether the debug mode is turned on or off.

.. deprecated:: 3.5

Use asyncio :ref:`asyncio-debug-mode` instead.

.. attribute:: on_response_prepare

A :class:`~aiohttp.Signal` that is fired at the beginning
2 changes: 1 addition & 1 deletion tests/test_client_functional.py
Original file line number Diff line number Diff line change
@@ -875,7 +875,7 @@ async def redirect(request):
raise web.HTTPFound(location='/')

data = json.dumps({'some': 'data'})
app = web.Application(debug=True)
app = web.Application()
app.router.add_get('/', handler)
app.router.add_post('/redirect', redirect)
client = await aiohttp_client(app)
6 changes: 5 additions & 1 deletion tests/test_web_app.py
Original file line number Diff line number Diff line change
@@ -61,9 +61,13 @@ def test_set_loop_with_different_loops() -> None:

@pytest.mark.parametrize('debug', [True, False])
async def test_app_make_handler_debug_exc(mocker, debug) -> None:
app = web.Application(debug=debug)
with pytest.warns(DeprecationWarning):
app = web.Application(debug=debug)
srv = mocker.patch('aiohttp.web_app.Server')

with pytest.warns(DeprecationWarning):
assert app.debug == debug

app._make_handler()
srv.assert_called_with(app._handle,
request_factory=app._make_request,