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

Python 3.7 support: async is a keyword #714

Closed
hroncok opened this issue May 18, 2018 · 19 comments
Closed

Python 3.7 support: async is a keyword #714

hroncok opened this issue May 18, 2018 · 19 comments

Comments

@hroncok
Copy link
Contributor

hroncok commented May 18, 2018

According to PEP 492, async and await are now keywords and cannot be used as names.

psycopg2 does:

  File "/usr/lib64/python3.7/site-packages/psycopg2/tests/test_async_keyword.py", line 43
    self.conn = self.connect(async=True)
                                 ^
SyntaxError: invalid syntax
  File "/usr/lib64/python3.7/site-packages/psycopg2/tests/test_cursor.py", line 570
    connect_func = lambda: self.connect(async=True)
                                            ^
SyntaxError: invalid syntax

Can this be renamed, to asynch maybe or async_?

@dvarrazzo
Copy link
Member

It is already fixed: since psycopg 2.7 you can use async_ instead. The tests should probably be fixed (at the moment Python 3.7 is not in travis) but the lib itself should work.

@hroncok
Copy link
Contributor Author

hroncok commented May 18, 2018

Running on Travis CI to see what happens BTW: https://travis-ci.org/hroncok/psycopg2/jobs/380610023

@hroncok
Copy link
Contributor Author

hroncok commented May 18, 2018

hroncok@fcd97d0

@hroncok
Copy link
Contributor Author

hroncok commented May 18, 2018

Would you accept a PR that fixes the tests and enables 3.7 on Travis?

@hroncok
Copy link
Contributor Author

hroncok commented May 18, 2018

Funny enough the tests pass as they are.

@dvarrazzo
Copy link
Member

test_async_keyword.py, as the name says, is conditionally excluded from the test suite, see tests/__init__.py. test_cursor.py seems broken and can be changed using async_.

@dvarrazzo
Copy link
Member

Of course I'm happy to accept running the tests on 3.7 too, thank you :)

@dvarrazzo
Copy link
Member

Weird the tests pass as they are. I would have expected test_cursor to fail importing.

@hroncok
Copy link
Contributor Author

hroncok commented May 18, 2018

ef64493

@dvarrazzo
Copy link
Member

As of 2.7 the tests were passing on python 3.7. The cursor test was broken in psycopg 2.7.2 by b203a7c

@dvarrazzo
Copy link
Member

ef64493

this is in master but not in maint_2_7. Will cherry-pick.

@hroncok
Copy link
Contributor Author

hroncok commented May 18, 2018

Thanks a lot. I've added 3.7 to Travis in #715

This issue can be considered invalid:

  • test_cursor was fixed in ef64493
  • test_async_keyword is skipped

@dvarrazzo
Copy link
Member

test_cursor fixed too. However 3.7 tests cannot run automatically on the branch maint_2_7 because it still supports Python 3.2, which instead is no more supported by recent pip versions (see this failure).

That's no big deal: I'd start push psycopg 2.8 instead.

@P-EB
Copy link

P-EB commented Jun 30, 2018

@dvarrazzo Debian migrated to python 3.7 in unstable. Do you have an ETA for 2.8? :)

Cheers!

@dvarrazzo
Copy link
Member

No, no release date yet, working on a couple of experimental branches.

However psycopg 2.7.5 runs perfectly well on python 3.7: try

$ make PYTHON=/usr/local/py37/bin/python3
$ make PYTHON=/usr/local/py37/bin/python3 check

@df7cb
Copy link
Contributor

df7cb commented Jun 30, 2018

At the moment, installing python3-psycopg2 2.7.5-1+b1 on Debian unstable explodes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=902715

@hroncok
Copy link
Contributor Author

hroncok commented Jun 30, 2018

@olasd
Copy link

olasd commented Jul 3, 2018

Thanks @hroncok for the pointer; I've done mostly the same thing when uploading an updated psycopg2 that fixes the install issue in Debian.

FWIW, @dvarrazzo, the concrete issue here is that when installing Python modules, Debian will byte-compile all files for all supported versions, even if they're never imported. The test_async_keyword.py file can't be byte-compiled by 3.7 (because it uses async as a variable), so the install blows up. The "fix" is to stop shipping the file in the binary packages.

Thanks for maintaining psycopg2, and sorry for the noise :)

@sammy-tam
Copy link

Thanks a lot. We have similar case where in our exist pipeline where we will manually compile all files with python3 -m compileall . and deploy the *.pyc only. Our current workaround is to remove the test_async_keyword.py before compiling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants