Skip to content

Commit

Permalink
12084 PyPy stack depth check change for 7.3.14 (twisted#12083)
Browse files Browse the repository at this point in the history
  • Loading branch information
glyph committed Jan 14, 2024
2 parents 0010216 + 5f68825 commit d827ff4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ jobs:
# extension.
# There is very little PYPY specific code so there is not much to
# gain from reporting coverage.
- python-version: 'pypy3.10-v7.3.13'
- python-version: 'pypy3.10-v7.3.14'
tox-env: 'alldeps-nocov-posix'
job-name: 'no-coverage'
skip-coverage: yes
Expand Down
11 changes: 8 additions & 3 deletions src/twisted/internet/defer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from contextvars import Context as _Context, copy_context as _copy_context
from enum import Enum
from functools import wraps
from sys import exc_info
from sys import exc_info, implementation
from types import CoroutineType, GeneratorType, MappingProxyType, TracebackType
from typing import (
TYPE_CHECKING,
Expand Down Expand Up @@ -58,6 +58,9 @@
_T = TypeVar("_T")
_P = ParamSpec("_P")

# See use in _inlineCallbacks for explanation and removal timeline.
_oldPypyStack = _PYPY and implementation.version < (7, 3, 14)


class AlreadyCalledError(Exception):
"""
Expand Down Expand Up @@ -2022,8 +2025,10 @@ def _inlineCallbacks(
appCodeTrace = traceback.tb_next
assert appCodeTrace is not None

if _PYPY:
# PyPy as of 3.7 adds an extra frame.
if _oldPypyStack:
# PyPy versions through 7.3.13 add an extra frame; 7.3.14 fixed
# this discrepancy with CPython. This code can be removed once
# we no longer need to support PyPy 7.3.13 or older.
appCodeTrace = appCodeTrace.tb_next
assert appCodeTrace is not None

Expand Down
1 change: 1 addition & 0 deletions src/twisted/newsfragments/12084.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
twisted.internet.defer.inlineCallbacks.returnValue's stack introspection was adjusted for the latest PyPy 7.3.14 release, allowing legacy @inlineCallbacks to run on new PyPY versions.

0 comments on commit d827ff4

Please sign in to comment.