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

Support and test PyPy 3.7 #1516

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
TOXENV: "alldeps-withcov-posix,coverage-prepare,codecov-push,coveralls-push"
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9, pypy3]
python-version: [3.5, 3.6, 3.7, 3.8, 3.9, pypy-3.6, pypy-3.7]
Copy link
Contributor

Choose a reason for hiding this comment

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

You should keep pypy3 here, in addition to adding pypy-3.6 and pypy-3.7.

Then after this release, we can remove pypy3 and keep pypy-3.6+

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems that pypy3 refers to 3.6. What do we need to keep it around for?

https://github.com/twisted/twisted/runs/1905976630?check_suite_focus=true
image

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah looks like specifying pypy3 in GitHub actions installs pypy3 compatible with Python 3.6.12.
So I think your change is fine, not worth fighting with GitHub about this.

Copy link
Contributor

Choose a reason for hiding this comment

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

This change is fine.


steps:
- uses: actions/checkout@v2
Expand Down
7 changes: 5 additions & 2 deletions src/twisted/internet/defer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import warnings
from asyncio import iscoroutine
from functools import wraps
from sys import exc_info, version_info
from sys import exc_info, implementation, version_info
from typing import Optional

import attr
Expand Down Expand Up @@ -1459,8 +1459,11 @@ def _inlineCallbacks(result, g, status):
# code.
appCodeTrace = exc_info()[2].tb_next

# The contextvars backport and our no-op shim add an extra frame.
if version_info < (3, 7):
# The contextvars backport and our no-op shim add an extra frame.
appCodeTrace = appCodeTrace.tb_next
Copy link
Contributor

Choose a reason for hiding this comment

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

so is the logic basically like:

 if (implementation.name == "cpython" and version_info < (3, 7)) or
     (implementation.name == "pypy" and version_info > (3, 6):
                # The contextvars backport and our no-op shim add an extra frame.
                # PyPy as of 3.7 adds an extra frame.
                appCodeTrace = appCodeTrace.tb_next

elif implementation.name == "pypy":
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like pypy 3.5, pypy 3.6, and pypy 3.7 behave differently.
Let's have this logic work on all three. Then after this release we can drop pypy 3.5

Copy link
Member Author

Choose a reason for hiding this comment

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

Current PyPy doesn't support 3.5. Do we need to add it into the mix? I'm not sure offhand if the action provides it but we can try.

Copy link
Contributor

@rodrigc rodrigc Feb 16, 2021

Choose a reason for hiding this comment

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

Looks like https://github.com/actions/setup-python#available-versions-of-pypy
specifies the versions of Pypy. I would say going through hoops to get Pypy 3.5 in Twisted CI is not worth the effort at this point.

Since we we specified pypy3 before, and that was installing pypy3 compatible with Python 3.6.12, then I see no point in introducing Pypy 3.5 at this point in the release cycle, when we are moving to drop support for Python 3.5/Ppy 3.5 after the release.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you manually install the last Pypy 3.5 release from:
https://downloads.python.org/pypy/pypy3.5-v7.0.0-linux64.tar.bz2
https://downloads.python.org/pypy/pypy3.5-v7.0.0-osx64.tar.bz2

And manually run test_inlinecb.py in your environment with your patch with this version of pypy?

I just want to double check, just in case there is a remote possibility that someone out there is running Pypy 3.5

Copy link
Member Author

Choose a reason for hiding this comment

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

$ git rev-parse HEAD
a225560007f04235596992da561adcf686c118ab
$ git diff
diff --git a/src/twisted/logger/_buffer.py b/src/twisted/logger/_buffer.py
index f90f8f982..3334f97e9 100644
--- a/src/twisted/logger/_buffer.py
+++ b/src/twisted/logger/_buffer.py
@@ -7,7 +7,7 @@ Log observer that maintains a buffer.
 """
 
 from collections import deque
-from typing import Deque, Optional
+from typing import Optional
 
 from zope.interface import implementer
 
$ venvpp35/bin/python --version --version
Python 3.5.3 (928a4f70d3de7d17449456946154c5da6e600162, Feb 09 2019, 11:50:43)
[PyPy 7.0.0 with GCC 8.2.0]
$ venvpp35/bin/trial twisted.internet.test.test_inlinecb
twisted.internet.test.test_inlinecb
  CancellationTests
    test_asynchronousCancellation ...                                      [OK]
    test_cascadeCancellingOnCancel ...                                     [OK]
    test_errbackCancelledErrorOnCancel ...                                 [OK]
    test_errorToErrorTranslation ...                                       [OK]
    test_errorToSuccessTranslation ...                                     [OK]
  ForwardTraceBackTests
    test_forwardLotsOfTracebacks ...                                       [OK]
    test_forwardTracebacks ...                                             [OK]
  NonLocalExitTests
    test_returnValueNonLocalDeferred ...                                   [OK]
    test_returnValueNonLocalWarning ...                                    [OK]
  StopIterationReturnTests
    test_returnWithValue ...                                               [OK]

-------------------------------------------------------------------------------
Ran 10 tests in 0.135s

PASSED (successes=10)

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

That's good enough for me.
No need change the CI to add Pypy 3.5. If someone encounters a problem, we can point them to this
log, and ask them to upgrade to Pypy 3.6 which is better tested/supported.

# PyPy as of 3.7 adds an extra frame.
appCodeTrace = appCodeTrace.tb_next

if isFailure:
Expand Down
1 change: 1 addition & 0 deletions src/twisted/newsfragments/10093.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PyPy 3.7 is now tested and supported.