Skip to content

Conversation

@vstinner
Copy link
Contributor

@vstinner vstinner commented Jul 3, 2018

Fix Python 3.7 support: handle also tstate->exc_info, not only
tstate->exc_state.

Fix Python 3.7 support: handle also tstate->exc_info, not only
tstate->exc_state.
@vstinner
Copy link
Contributor Author

vstinner commented Jul 3, 2018

@markshannon: Would you mind to review my greenlet fix for Python 3.7, please?

@vstinner
Copy link
Contributor Author

vstinner commented Jul 3, 2018

cc @hroncok

Copy link
Contributor

@snaury snaury left a comment

Choose a reason for hiding this comment

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

Looks good. I'm a little worried about correctness of exc_info links, but I guess since you can't enter generators twice it's good. There's no visiting of exceptions that are on generator chains, but it's all good since gc doesn't work for live greenlets anyway.

Might be better if we actually make greenlet's exc_state root of the hierarchy instead of tstate->exc_state, then we would only need to save/restore the exc_info pointer, not actual exception objects, although it may be harder to prove that it's always correct.

greenlet.c Outdated
#define GREENLET_tp_is_gc 0
#endif /* !GREENLET_USE_GC */

static void green_clear_exc(PyGreenlet *g)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please change it to PyGreenlet* g?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, sorry, fixed

greenlet.h Outdated
int recursion_depth;
PyObject* weakreflist;
#ifdef GREENLET_USE_EXC_INFO
_PyErr_StackItem *exc_info;
Copy link
Contributor

Choose a reason for hiding this comment

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

Here as well, _PyErr_StackItem* exc_info

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

greenlet.c Outdated
tstate->exc_state.exc_traceback = target->exc_traceback;
#ifdef GREENLET_USE_EXC_INFO
tstate->exc_state = target->exc_state;
if (target->exc_info != NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it might be better as a single line: tstate->exc_info = target->exc_info ? target->exc_info : &tstate->exc_state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@vstinner
Copy link
Contributor Author

vstinner commented Jul 3, 2018

Oh, by the way, I tested manually my PR on Python 3.6 and 3.7 using virtual environments and the commands:

python setup.py build
python run-tests.py
python dagpool_test.py

where dagpool_test.py comes from: https://bugs.python.org/issue33996

dagpool_test.py is the highly simplified code of eventlet test "tests.dagpool_test.test_propagate_exc".

@vstinner
Copy link
Contributor Author

vstinner commented Jul 3, 2018

Ha ha, the 3.7 job of Travis CI failed... on downloading Python!

Network availability confirmed.

3.7 is not installed; attempting download
Downloading archive: https://s3.amazonaws.com/travis-python-archives/binaries/ubuntu/14.04/x86_64/python-3.7.tar.bz2
$ curl -sSf -o python-3.7.tar.bz2 ${archive_url}
curl: (22) The requested URL returned error: 403 Forbidden
Unable to download 3.7 archive. The archive may not exist. Please consider a different version.

Can someone rebuild this job please?

@vstinner
Copy link
Contributor Author

vstinner commented Jul 3, 2018

I just tested the master branch eventlet with the master branch of greenlet: "python -m nose -v tests" no longer crash with this greenlet change. In short, this change fixes eventlet/eventlet#475

@vstinner vstinner closed this Jul 4, 2018
@vstinner vstinner reopened this Jul 4, 2018
@vstinner
Copy link
Contributor Author

vstinner commented Jul 4, 2018

I closed/reopened my PR just to re-trigger the Travis CI job. I would like to see a green job for Python 3.7 on Travis CI :-)

@vstinner
Copy link
Contributor Author

vstinner commented Jul 4, 2018

Oh. 3.7 still fails with a download error on Travis CI, but it seems like the issue comes from Travis, not greenlet:

3.7 is not installed; attempting download
Downloading archive: https://s3.amazonaws.com/travis-python-archives/binaries/ubuntu/14.04/x86_64/python-3.7.tar.bz2
$ curl -sSf -o python-3.7.tar.bz2 ${archive_url}
curl: (22) The requested URL returned error: 403 Forbidden
Unable to download 3.7 archive. The archive may not exist. Please consider a different version.

@hroncok
Copy link

hroncok commented Jul 4, 2018

Only alpha or beta on Travis with 3.7-dev

@vstinner
Copy link
Contributor Author

vstinner commented Jul 4, 2018

Only alpha or beta on Travis with 3.7-dev

Let me try with "3.7-dev" in .travis.yml.

It's possible to get 3.7 final with more complex config, but I don't think that it's worth it here. 3.7-dev should be fine until Travis CI officially support 3.7 final.

https://twitter.com/codewithanthony/status/1014168756342251521

\o/ @travisci now has `python: 3.7` for `dist: xenial`

 - env: TOXENV=py37
   python: 3.7
   sudo: required
   dist: xenial

@vstinner
Copy link
Contributor Author

vstinner commented Jul 4, 2018

Say hello to green 3.7 job on Travis CI!

@vstinner
Copy link
Contributor Author

vstinner commented Jul 4, 2018

The two Python 3.7 jobs (32 and 64 bits) on Windows (AppVeyor) as also green ;-)

@snaury
Copy link
Contributor

snaury commented Jul 4, 2018

The two Python 3.7 jobs (32 and 64 bits) on Windows (AppVeyor) as also green ;-)

Unfortunately neither Travis nor AppVeyor currently support Python 3.7 release. AppVeyor job actually lies, as it's currently testing and building using Python 2.7 (which is in PATH by default). :-/

@snaury snaury merged commit d3cd905 into python-greenlet:master Jul 4, 2018
@snaury
Copy link
Contributor

snaury commented Jul 4, 2018

Thanks for the patch, I will postpone release until AppVeyor releases new images (appveyor/ci#2475)

@vstinner vstinner deleted the py37 branch July 4, 2018 21:32
robertknight added a commit to hypothesis/h that referenced this pull request Jul 24, 2018
See gevent/gevent#1069

Note that greenlet 0.4.13 is missing a change required for Python 3.7
[1] but we are still using Python 3.6 in production, so this shouldn't
be a problem.

[1] python-greenlet/greenlet#132
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

Successfully merging this pull request may close these issues.

3 participants