Skip to content

Commit

Permalink
drop support to python <3.5.3 (aio-libs#2435)
Browse files Browse the repository at this point in the history
* drop support to python <3.5.3

* drop helpers.create_future

* drop helpers.isfuture

* fix rebase

* drop ci specific test on 3.5.3
  • Loading branch information
jairhenrique authored and asvetlov committed Oct 30, 2017
1 parent 26ff9d8 commit 8e9c6b5
Show file tree
Hide file tree
Showing 32 changed files with 143 additions and 217 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ sudo: false
language: python

python:
- 3.5.2
- 3.5
- &mainstream_python 3.6
- 3.6-dev
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def update_expect_continue(self, expect=False):
expect = True

if expect:
self._continue = helpers.create_future(self.loop)
self._continue = self.loop.create_future()

def update_proxy(self, proxy, proxy_auth, proxy_headers):
if proxy and not proxy.scheme == 'http':
Expand Down
7 changes: 2 additions & 5 deletions aiohttp/client_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import async_timeout

from .client_exceptions import ClientError
from .helpers import PY_352, call_later, create_future
from .helpers import call_later
from .http import (WS_CLOSED_MESSAGE, WS_CLOSING_MESSAGE, WebSocketError,
WSMessage, WSMsgType)

Expand Down Expand Up @@ -186,7 +186,7 @@ async def receive(self, timeout=None):
return WS_CLOSED_MESSAGE

try:
self._waiting = create_future(self._loop)
self._waiting = self._loop.create_future()
try:
with async_timeout.timeout(
timeout or self._receive_timeout,
Expand Down Expand Up @@ -253,9 +253,6 @@ async def receive_json(self, *, loads=json.loads, timeout=None):
def __aiter__(self):
return self

if not PY_352: # pragma: no cover
__aiter__ = asyncio.coroutine(__aiter__)

async def __anext__(self):
msg = await self.receive()
if msg.type in (WSMsgType.CLOSE,
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ async def connect(self, req):

# Wait if there are no available connections.
if available <= 0:
fut = helpers.create_future(self._loop)
fut = self._loop.create_future()

# This connection will now count towards the limit.
waiters = self._waiters[key]
Expand Down
21 changes: 0 additions & 21 deletions aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import inspect
import os
import re
import sys
import time
import warnings
import weakref
Expand All @@ -29,9 +28,6 @@
from .log import client_logger


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


__all__ = ('BasicAuth',)


Expand Down Expand Up @@ -135,13 +131,6 @@ def deprecated_noop(message):
coroutines._DEBUG = old_debug


try:
from asyncio import isfuture
except ImportError:
def isfuture(fut):
return isinstance(fut, asyncio.Future)


class BasicAuth(namedtuple('BasicAuth', ['login', 'password', 'encoding'])):
"""Http basic authentication helper."""

Expand Down Expand Up @@ -219,16 +208,6 @@ def proxies_from_env():
return ret


if PY_352:
def create_future(loop):
return loop.create_future()
else:
def create_future(loop): # pragma: no cover
"""Compatibility wrapper for the loop.create_future() call introduced in
3.5.2."""
return asyncio.Future(loop=loop)


def current_task(loop=None):
if loop is None:
loop = asyncio.get_event_loop()
Expand Down
4 changes: 2 additions & 2 deletions aiohttp/http_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import zlib

from .abc import AbstractPayloadWriter
from .helpers import create_future, noop
from .helpers import noop


__all__ = ('PayloadWriter', 'HttpVersion', 'HttpVersion10', 'HttpVersion11',
Expand Down Expand Up @@ -292,6 +292,6 @@ def drain(self, last=False):
else:
# wait for transport
if self._drain_waiter is None:
self._drain_waiter = create_future(self.loop)
self._drain_waiter = self.loop.create_future()

yield from self._drain_waiter
11 changes: 1 addition & 10 deletions aiohttp/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from .hdrs import (CONTENT_DISPOSITION, CONTENT_ENCODING, CONTENT_LENGTH,
CONTENT_TRANSFER_ENCODING, CONTENT_TYPE)
from .helpers import CHAR, PY_352, TOKEN, parse_mimetype, reify
from .helpers import CHAR, TOKEN, parse_mimetype, reify
from .http import HttpParser
from .payload import (BytesPayload, LookupError, Payload, StringPayload,
get_payload, payload_type)
Expand Down Expand Up @@ -172,9 +172,6 @@ def __init__(self, resp, stream):
def __aiter__(self):
return self

if not PY_352: # pragma: no cover
__aiter__ = asyncio.coroutine(__aiter__)

@asyncio.coroutine
def __anext__(self):
part = yield from self.next()
Expand Down Expand Up @@ -223,9 +220,6 @@ def __init__(self, boundary, headers, content):
def __aiter__(self):
return self

if not PY_352: # pragma: no cover
__aiter__ = asyncio.coroutine(__aiter__)

@asyncio.coroutine
def __anext__(self):
part = yield from self.next()
Expand Down Expand Up @@ -545,9 +539,6 @@ def __init__(self, headers, content):
def __aiter__(self):
return self

if not PY_352: # pragma: no cover
__aiter__ = asyncio.coroutine(__aiter__)

@asyncio.coroutine
def __anext__(self):
part = yield from self.next()
Expand Down
3 changes: 1 addition & 2 deletions aiohttp/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from itertools import count

from aiohttp.frozenlist import FrozenList
from aiohttp.helpers import isfuture


class BaseSignal(FrozenList):
Expand All @@ -12,7 +11,7 @@ class BaseSignal(FrozenList):
async def _send(self, *args, **kwargs):
for receiver in self:
res = receiver(*args, **kwargs)
if asyncio.iscoroutine(res) or isfuture(res):
if asyncio.iscoroutine(res) or asyncio.isfuture(res):
await res


Expand Down
16 changes: 3 additions & 13 deletions aiohttp/streams.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import asyncio
import collections

from . import helpers
from .log import internal_logger


Expand All @@ -25,9 +24,6 @@ def __init__(self, read_func):
def __aiter__(self):
return self

if not helpers.PY_352: # pragma: no cover
__aiter__ = asyncio.coroutine(__aiter__)

async def __anext__(self):
try:
rv = await self.read_func()
Expand All @@ -51,9 +47,6 @@ class AsyncStreamReaderMixin:
def __aiter__(self):
return AsyncStreamIterator(self.readline)

if not helpers.PY_352: # pragma: no cover
__aiter__ = asyncio.coroutine(__aiter__)

def iter_chunked(self, n):
"""Returns an asynchronous iterator that yields chunks of size n.
Expand Down Expand Up @@ -190,7 +183,7 @@ async def wait_eof(self):
return

assert self._eof_waiter is None
self._eof_waiter = helpers.create_future(self._loop)
self._eof_waiter = self._loop.create_future()
try:
await self._eof_waiter
finally:
Expand Down Expand Up @@ -247,7 +240,7 @@ async def _wait(self, func_name):
raise RuntimeError('%s() called while another coroutine is '
'already waiting for incoming data' % func_name)

waiter = self._waiter = helpers.create_future(self._loop)
waiter = self._waiter = self._loop.create_future()
try:
if self._timer:
with self._timer:
Expand Down Expand Up @@ -532,7 +525,7 @@ def feed_eof(self):
async def read(self):
if not self._buffer and not self._eof:
assert not self._waiter
self._waiter = helpers.create_future(self._loop)
self._waiter = self._loop.create_future()
try:
await self._waiter
except (asyncio.CancelledError, asyncio.TimeoutError):
Expand All @@ -552,9 +545,6 @@ async def read(self):
def __aiter__(self):
return AsyncStreamIterator(self.read)

if not helpers.PY_352: # pragma: no cover
__aiter__ = asyncio.coroutine(__aiter__)


class ChunksQueue(DataQueue):
"""Like a :class:`DataQueue`, but for binary chunked data transfer."""
Expand Down
5 changes: 2 additions & 3 deletions aiohttp/web_fileresponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import pathlib

from . import hdrs
from .helpers import create_future
from .http_writer import PayloadWriter
from .log import server_logger
from .web_exceptions import (HTTPNotModified, HTTPOk, HTTPPartialContent,
Expand Down Expand Up @@ -57,7 +56,7 @@ def _sendfile_cb(self, fut, out_fd, in_fd,
async def sendfile(self, fobj, count):
if self._transport is None:
if self._drain_waiter is None:
self._drain_waiter = create_future(self.loop)
self._drain_waiter = self.loop.create_future()

await self._drain_waiter

Expand All @@ -70,7 +69,7 @@ async def sendfile(self, fobj, count):
loop = self.loop
try:
await loop.sock_sendall(out_socket, b''.join(self._buffer))
fut = create_future(loop)
fut = loop.create_future()
self._sendfile_cb(fut, out_fd, in_fd, offset, count, loop, False)
await fut
except Exception:
Expand Down
4 changes: 2 additions & 2 deletions aiohttp/web_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from html import escape as html_escape

from . import helpers, http
from .helpers import CeilTimeout, create_future
from .helpers import CeilTimeout
from .http import (HttpProcessingError, HttpRequestParser, PayloadWriter,
StreamWriter)
from .log import access_logger, server_logger
Expand Down Expand Up @@ -492,7 +492,7 @@ async def start(self, message, payload, handler):
self._process_keepalive)

# wait for next request
waiter = create_future(loop)
waiter = loop.create_future()
self._waiters.append(waiter)
try:
message, payload = await waiter
Expand Down
7 changes: 2 additions & 5 deletions aiohttp/web_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import async_timeout

from . import hdrs
from .helpers import PY_352, call_later, create_future
from .helpers import call_later
from .http import (WS_CLOSED_MESSAGE, WS_CLOSING_MESSAGE, HttpProcessingError,
WebSocketError, WebSocketReader, WSMessage, WSMsgType,
do_handshake)
Expand Down Expand Up @@ -272,7 +272,7 @@ async def receive(self, timeout=None):
return WS_CLOSING_MESSAGE

try:
self._waiting = create_future(self._loop)
self._waiting = self._loop.create_future()
try:
with async_timeout.timeout(
timeout or self._receive_timeout, loop=self._loop):
Expand Down Expand Up @@ -337,9 +337,6 @@ def write(self, data):
def __aiter__(self):
return self

if not PY_352: # pragma: no cover
__aiter__ = asyncio.coroutine(__aiter__)

async def __anext__(self):
msg = await self.receive()
if msg.type in (WSMsgType.CLOSE,
Expand Down
4 changes: 2 additions & 2 deletions aiohttp/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from gunicorn.config import AccessLogFormat as GunicornAccessLogFormat
from gunicorn.workers import base

from .helpers import AccessLogger, create_future
from .helpers import AccessLogger


try:
Expand Down Expand Up @@ -143,7 +143,7 @@ async def _run(self):
def _wait_next_notify(self):
self._notify_waiter_done()

self._notify_waiter = waiter = create_future(self.loop)
self._notify_waiter = waiter = self.loop.create_future()
self.loop.call_later(1.0, self._notify_waiter_done)

return waiter
Expand Down
5 changes: 3 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
import codecs
import os
import re
import sys


_docs_path = os.path.dirname(__file__)
_version_path = os.path.abspath(os.path.join(_docs_path,
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from setuptools import Extension, setup
from setuptools.command.test import test as TestCommand


try:
from Cython.Build import cythonize
USE_CYTHON = True
Expand Down
3 changes: 1 addition & 2 deletions tests/test_client_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import aiohttp
from aiohttp import ServerFingerprintMismatch, hdrs, web
from aiohttp.abc import AbstractResolver
from aiohttp.helpers import create_future
from aiohttp.multipart import MultipartWriter


Expand Down Expand Up @@ -585,7 +584,7 @@ async def handler(request):

async def test_timeout_on_reading_data(loop, test_client, mocker):
mocker.patch('aiohttp.helpers.ceil').side_effect = ceil
fut = create_future(loop=loop)
fut = loop.create_future()

async def handler(request):
resp = web.StreamResponse(headers={'content-length': '100'})
Expand Down
6 changes: 3 additions & 3 deletions tests/test_client_functional_oldstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def run(loop, fut):
host, port, ssl=sslcontext)
server = thread_loop.run_until_complete(server_coroutine)

waiter = helpers.create_future(thread_loop)
waiter = thread_loop.create_future()
loop.call_soon_threadsafe(
fut.set_result, (thread_loop, waiter,
server.sockets[0].getsockname()))
Expand All @@ -117,7 +117,7 @@ def run(loop, fut):
thread_loop.close()
gc.collect()

fut = helpers.create_future(loop)
fut = loop.create_future()
server_thread = threading.Thread(target=run, args=(loop, fut))
server_thread.start()

Expand Down Expand Up @@ -457,7 +457,7 @@ def test_POST_STREAM_DATA(self):
with open(fname, 'rb') as f:
data = f.read()

fut = helpers.create_future(self.loop)
fut = self.loop.create_future()

@aiohttp.streamer
async def stream(writer):
Expand Down
Loading

0 comments on commit 8e9c6b5

Please sign in to comment.