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

VCRPy 2.0.0 doesn't work on 3.4 anymore #393

Closed
lmazuel opened this issue Sep 20, 2018 · 8 comments
Closed

VCRPy 2.0.0 doesn't work on 3.4 anymore #393

lmazuel opened this issue Sep 20, 2018 · 8 comments

Comments

@lmazuel
Copy link
Contributor

lmazuel commented Sep 20, 2018

My Travis job is now failing on 3.4:

    import vcr
../../../virtualenv/python3.4.6/lib/python3.4/site-packages/vcr/__init__.py:2: in <module>
    from .config import VCR
../../../virtualenv/python3.4.6/lib/python3.4/site-packages/vcr/config.py:10: in <module>
    from .cassette import Cassette
../../../virtualenv/python3.4.6/lib/python3.4/site-packages/vcr/cassette.py:19: in <module>
    from ._handle_coroutine import handle_coroutine
E     File "/home/travis/virtualenv/python3.4.6/lib/python3.4/site-packages/vcr/_handle_coroutine.py", line 1
E       async def handle_coroutine(vcr, fn):  # noqa: E999
E               ^
E   SyntaxError: invalid syntax

I did nothing else than installing the 2.0.0 and starting the same job as usual (requests based recording).

Does VCRPy 2.0.0 still supports 3.4? The 2.7 job works as expected, so my guess is there is condition a little loose on loading async code.

@lamenezes
Copy link
Collaborator

aiohttp stub doesn't work for python 3.4 on vcrpy 2.0 as stated on the changelog [1] and the release notes [2].

[1] https://vcrpy.readthedocs.io/en/latest/changelog.html
[2] https://github.com/kevin1024/vcrpy/releases/tag/v2.0.0

@lmazuel
Copy link
Contributor Author

lmazuel commented Sep 20, 2018

@lamenezes I don't use aiohttp at all, just requests. If you look closely, this stacktrace comes from import vcr, so there is nothing I can do.

If VCRPy as a whole is not compatible with 3.4 I have no trouble with that, but then make it clear in ChangeLog: VCRPy does not support 3.4 anymore. And on PyPi as well (3.4 descriptor is still there).

@lmazuel
Copy link
Contributor Author

lmazuel commented Sep 20, 2018

Found the issue in the code:

try:
    from asyncio import iscoroutinefunction
    from ._handle_coroutine import handle_coroutine
except ImportError:
    def iscoroutinefunction(*args, **kwargs):
        return False

    def handle_coroutine(*args, **kwags):
        raise NotImplementedError('Not implemented on Python 2')

In Python 2.7, asyncio does not exist, so you get an ImportError, which is caught here. On Python 3.4, asyncio does exist, so the second line is tried to e imported. this file contains async/await syntax, which is not valid in 3.4, and raise a SyntaxError. This one is not caught.

Possible fix would be to split this into asyncio / ImportError in one try/except, and handle_coroutine / SyntaxError in another try / except. Or just double the except (ImportError, SyntaxError)

@aqw
Copy link

aqw commented Sep 21, 2018

If Python 3.4 is going to be dropped, then setup.py and .travis.yml should be updated accordingly.

wmfgerrit pushed a commit to wikimedia/pywikibot that referenced this issue Sep 21, 2018
nose-detecthttp requires vcrpy. vcrpy 2.0.0 has had a breaking change which
makes it incompatible with Python<3.5.[1]

The root issue should be fixed upstream, but till then avoid vcrpy 2.0.0.

[1]: kevin1024/vcrpy#393

Bug: T205073
Change-Id: I391bddea1dcfa0c9f214aa6ecc3827423199f904
@lamenezes
Copy link
Collaborator

Thanks for opening the issue and helping debug @lmazuel. I've just released vcrpy 2.0.1 and it should now work correctly with python 3.4.

wmfgerrit pushed a commit to wikimedia/pywikibot that referenced this issue Sep 24, 2018
This reverts commit 53a3f20.

Reason for revert: The upstream issue has been resolved.[1]

[1]:
kevin1024/vcrpy#393

Bug: T205073
Change-Id: I3ed7635f9b8fed2252c4db8dce27e0d06dbe6cff
@jxltom
Copy link
Contributor

jxltom commented Nov 13, 2018

Hi @lamenezes, currentlly vcrpy requires yarl which does not support python34 anymore from 1.2. Refer to aio-libs/yarl#205. This makes vcrpy can not work in python 3.4. Should vcrpy pin with older versions of yarl?

There is a issue #342 related with this.

@lamenezes
Copy link
Collaborator

@jxltom well pointed! I think we should pin yarl only for python3.4. can you open a PR fixing this? 🙂

@jxltom
Copy link
Contributor

jxltom commented Nov 14, 2018

@lamenezes Sure, PR #409 is up. :D

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

4 participants