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

python3.7 support #437

Merged
merged 17 commits into from Aug 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions .travis.yml
Expand Up @@ -9,8 +9,22 @@ python:
- "3.4"
- "3.5"
- "3.6"
- "nightly"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Want to replace "nightly" -> "3.7" but there is issue about Travis and python 3.7: travis-ci/travis-ci#9815

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add a job with specific settings for that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind. I did this.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@webknjaz nice. Did you mean to leave in the nightly build? Not opposed to it either way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nightly points to 3.8-dev now.


.mixtures:
- &py3_7-base
python: "3.7"
dist: xenial
sudo: required
jobs:
include:
- <<: *py3_7-base

- <<: *py3_7-base
env:

install:
- pip install -U setuptools
- python setup.py install
- pip install -Ur requirements.txt
- pip install codecov
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -8,7 +8,7 @@ pep:
pep8 aiopg examples tests

flake:
extra=$$(python -c "import sys;sys.stdout.write('--exclude tests/pep492') if sys.version_info[:3] < (3, 5, 0) else sys.stdout.write('examples')"); \
extra=$$(python -c "import sys;sys.stdout.write('--exclude tests/pep492 --builtins=StopAsyncIteration') if sys.version_info[:3] < (3, 5, 0) else sys.stdout.write('examples')"); \
flake8 aiopg tests $$extra

test: flake
Expand Down
2 changes: 1 addition & 1 deletion aiopg/connection.py
Expand Up @@ -106,7 +106,7 @@ class Connection:

def __init__(self, dsn, loop, timeout, waiter, echo, **kwargs):
self._loop = loop
self._conn = psycopg2.connect(dsn, async=True, **kwargs)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

self._conn = psycopg2.connect(dsn, async_=True, **kwargs)
self._dsn = self._conn.dsn
assert self._conn.isexecuting(), "Is conn an async at all???"
self._fileno = self._conn.fileno()
Expand Down
4 changes: 2 additions & 2 deletions aiopg/cursor.py
Expand Up @@ -384,7 +384,7 @@ def __iter__(self):
while True:
row = yield from self.fetchone()
if row is None:
raise StopIteration
return
else:
yield row

Expand All @@ -402,7 +402,7 @@ def __anext__(self):
if ret is not None:
return ret
else:
raise StopAsyncIteration # noqa
raise StopAsyncIteration

@asyncio.coroutine
def __aenter__(self):
Expand Down
4 changes: 2 additions & 2 deletions aiopg/sa/result.py
Expand Up @@ -335,7 +335,7 @@ def __iter__(self):
while True:
row = yield from self.fetchone()
if row is None:
raise StopIteration
return
else:
yield row

Expand All @@ -353,7 +353,7 @@ def __anext__(self):
if ret is not None:
return ret
else:
raise StopAsyncIteration # noqa
raise StopAsyncIteration

def _non_result(self):
if self._metadata is None:
Expand Down
17 changes: 15 additions & 2 deletions aiopg/utils.py
Expand Up @@ -15,7 +15,7 @@
try:
ensure_future = asyncio.ensure_future
except AttributeError:
ensure_future = asyncio.async
ensure_future = getattr(asyncio, 'async')


def create_future(loop):
Expand Down Expand Up @@ -86,7 +86,20 @@ class _SAConnectionContextManager(_ContextManager):
if PY_35: # pragma: no branch
if PY_352:
def __aiter__(self):
return self._coro
return self

@asyncio.coroutine
def __anext__(self):
if self._obj is None:
self._obj = yield from self._coro

try:
return (yield from self._obj.__anext__())
except StopAsyncIteration:
self._obj.close()
self._obj = None
raise

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, we would just make __aiter__ an async generator so we don't have to supply this __anext__ proxying code, but this would break for the small handful of CPython releases >=3.5.2 and <3.6


else:
@asyncio.coroutine
def __aiter__(self):
Expand Down
1 change: 1 addition & 0 deletions tests/test_pool.py
Expand Up @@ -343,6 +343,7 @@ def test_true_parallel_tasks(create_pool, loop):
maxsize = 0
minfreesize = 100

@asyncio.coroutine
def inner():
nonlocal maxsize, minfreesize
maxsize = max(maxsize, pool.size)
Expand Down