Skip to content

Commit

Permalink
Fix #1178: Restore aiohttp.web.MsgType alias for aiohttp.WSMsgType fo…
Browse files Browse the repository at this point in the history
…r sake of backward compatibility
  • Loading branch information
asvetlov committed Sep 16, 2016
1 parent fdff446 commit d306414
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CHANGES
=======

1.0.1 (XX-XX-XXXX)
------------------

- Restore `aiohttp.web.MsgType` alias for `aiohttp.WSMsgType` for sake
of backward compatibility #1178


1.0.0 (09-16-2016)
-------------------

Expand Down
4 changes: 3 additions & 1 deletion aiohttp/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
from .web_urldispatcher import * # noqa
from .web_ws import * # noqa


__all__ = (web_reqrep.__all__ +
web_exceptions.__all__ +
web_urldispatcher.__all__ +
web_ws.__all__ +
('Application', 'RequestHandler',
'RequestHandlerFactory', 'HttpVersion'))
'RequestHandlerFactory', 'HttpVersion',
'MsgType'))


class RequestHandler(ServerHttpProtocol):
Expand Down
6 changes: 5 additions & 1 deletion aiohttp/web_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@
HTTPMethodNotAllowed)
from .web_reqrep import StreamResponse

__all__ = ('WebSocketResponse',)
__all__ = ('WebSocketResponse', 'WebSocketReady', 'MsgType')

PY_35 = sys.version_info >= (3, 5)
PY_352 = sys.version_info >= (3, 5, 2)

THRESHOLD_CONNLOST_ACCESS = 5


# deprecated since 1.0
MsgType = WSMsgType


class WebSocketReady(namedtuple('WebSocketReady', 'ok protocol')):
def __bool__(self):
return self.ok
Expand Down
8 changes: 7 additions & 1 deletion tests/test_web_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

import pytest

from aiohttp import CIMultiDict, WSMessage, WSMsgType, errors, helpers, signals
from aiohttp import (CIMultiDict, WSMessage, WSMsgType, errors, helpers,
signals, web)
from aiohttp.test_utils import make_mocked_coro, make_mocked_request
from aiohttp.web import HTTPBadRequest, HTTPMethodNotAllowed, WebSocketResponse
from aiohttp.web_ws import WebSocketReady
Expand Down Expand Up @@ -500,3 +501,8 @@ def test_can_start_ok(make_request):
ws = WebSocketResponse(protocols=('chat',))
with pytest.warns(DeprecationWarning):
assert (True, 'chat') == ws.can_start(req)


def test_msgtype_alias():
# deprecated since 1.0
assert web.MsgType is WSMsgType

0 comments on commit d306414

Please sign in to comment.