Skip to content

Commit

Permalink
#11857 test on py 3.12rc (#11910)
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert committed Aug 16, 2023
2 parents a9ee8e5 + 61cae87 commit 9a2ea00
Show file tree
Hide file tree
Showing 13 changed files with 1,120 additions and 16 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/test.yaml
Expand Up @@ -69,7 +69,7 @@ jobs:
# The Python version on which the job is executed.
# We need at least one value here, so we go with latest Python version
# that we support..
python-version: ['3.10']
python-version: ['3.11']
# Just use the default OS.
runs-on: ['']
# Human readable short description for this job.
Expand Down Expand Up @@ -124,8 +124,11 @@ jobs:
# Just Python 3.9 with default settings.
- python-version: '3.9'

# Just Python 3.11 with default settings.
- python-version: '3.11'
# Just Python 3.10 with default settings.
- python-version: '3.10'

# Just Python 3.12 with default settings.
- python-version: '3.12'

# Newest macOS and newest Python supported versions.
- python-version: '3.11'
Expand Down Expand Up @@ -184,6 +187,7 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Get pip cache dir
id: pip-cache
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Expand Up @@ -28,6 +28,8 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"zope.interface >= 5",
Expand Down
7 changes: 5 additions & 2 deletions src/twisted/internet/defer.py
Expand Up @@ -9,6 +9,7 @@
"""
from __future__ import annotations

import inspect
import traceback
import warnings
from abc import ABC, abstractmethod
Expand Down Expand Up @@ -1341,8 +1342,10 @@ def main(reactor):
@raise ValueError: If C{coro} is not a coroutine or generator.
"""
# asyncio.iscoroutine identifies generators as coroutines, too.
if iscoroutine(coro):
# asyncio.iscoroutine <3.12 identifies generators as coroutines, too.
# for >=3.12 we need to check isgenerator also
# see https://github.com/python/cpython/issues/102748
if iscoroutine(coro) or inspect.isgenerator(coro):
return _cancellableInlineCallbacks(coro)
raise NotACoroutineError(f"{coro!r} is not a coroutine")

Expand Down
1 change: 1 addition & 0 deletions src/twisted/newsfragments/11857.feature
@@ -0,0 +1 @@
The CI suite was updated to execute the tests using a Python 3.12 pre-release
2 changes: 2 additions & 0 deletions src/twisted/newsfragments/11908.bugfix
@@ -0,0 +1,2 @@
utcfromtimestamp has been deprecated since Python 3.12,
use fromtimestamp(x, timezone.utc).replace(tzinfo=None) instead.
150 changes: 150 additions & 0 deletions src/twisted/persisted/_token.py
@@ -0,0 +1,150 @@
"""
FIXME:https://github.com/twisted/twisted/issues/3843
This can be removed once t.persisted.aot is removed.
New code should not make use of this.
Token constants.
vendored from https://github.com/python/cpython/blob/6b825c1b8a14460641ca6f1647d83005c68199aa/Lib/token.py
Licence: https://docs.python.org/3/license.html
"""
# Auto-generated by Tools/scripts/generate_token.py

__all__ = ["tok_name", "ISTERMINAL", "ISNONTERMINAL", "ISEOF"]

ENDMARKER = 0
NAME = 1
NUMBER = 2
STRING = 3
NEWLINE = 4
INDENT = 5
DEDENT = 6
LPAR = 7
RPAR = 8
LSQB = 9
RSQB = 10
COLON = 11
COMMA = 12
SEMI = 13
PLUS = 14
MINUS = 15
STAR = 16
SLASH = 17
VBAR = 18
AMPER = 19
LESS = 20
GREATER = 21
EQUAL = 22
DOT = 23
PERCENT = 24
LBRACE = 25
RBRACE = 26
EQEQUAL = 27
NOTEQUAL = 28
LESSEQUAL = 29
GREATEREQUAL = 30
TILDE = 31
CIRCUMFLEX = 32
LEFTSHIFT = 33
RIGHTSHIFT = 34
DOUBLESTAR = 35
PLUSEQUAL = 36
MINEQUAL = 37
STAREQUAL = 38
SLASHEQUAL = 39
PERCENTEQUAL = 40
AMPEREQUAL = 41
VBAREQUAL = 42
CIRCUMFLEXEQUAL = 43
LEFTSHIFTEQUAL = 44
RIGHTSHIFTEQUAL = 45
DOUBLESTAREQUAL = 46
DOUBLESLASH = 47
DOUBLESLASHEQUAL = 48
AT = 49
ATEQUAL = 50
RARROW = 51
ELLIPSIS = 52
COLONEQUAL = 53
OP = 54
AWAIT = 55
ASYNC = 56
TYPE_IGNORE = 57
TYPE_COMMENT = 58
SOFT_KEYWORD = 59
# These aren't used by the C tokenizer but are needed for tokenize.py
ERRORTOKEN = 60
COMMENT = 61
NL = 62
ENCODING = 63
N_TOKENS = 64
# Special definitions for cooperation with parser
NT_OFFSET = 256

tok_name = {
value: name
for name, value in globals().items()
if isinstance(value, int) and not name.startswith("_")
}
__all__.extend(tok_name.values())

EXACT_TOKEN_TYPES = {
"!=": NOTEQUAL,
"%": PERCENT,
"%=": PERCENTEQUAL,
"&": AMPER,
"&=": AMPEREQUAL,
"(": LPAR,
")": RPAR,
"*": STAR,
"**": DOUBLESTAR,
"**=": DOUBLESTAREQUAL,
"*=": STAREQUAL,
"+": PLUS,
"+=": PLUSEQUAL,
",": COMMA,
"-": MINUS,
"-=": MINEQUAL,
"->": RARROW,
".": DOT,
"...": ELLIPSIS,
"/": SLASH,
"//": DOUBLESLASH,
"//=": DOUBLESLASHEQUAL,
"/=": SLASHEQUAL,
":": COLON,
":=": COLONEQUAL,
";": SEMI,
"<": LESS,
"<<": LEFTSHIFT,
"<<=": LEFTSHIFTEQUAL,
"<=": LESSEQUAL,
"=": EQUAL,
"==": EQEQUAL,
">": GREATER,
">=": GREATEREQUAL,
">>": RIGHTSHIFT,
">>=": RIGHTSHIFTEQUAL,
"@": AT,
"@=": ATEQUAL,
"[": LSQB,
"]": RSQB,
"^": CIRCUMFLEX,
"^=": CIRCUMFLEXEQUAL,
"{": LBRACE,
"|": VBAR,
"|=": VBAREQUAL,
"}": RBRACE,
"~": TILDE,
}


def ISTERMINAL(x):
return x < NT_OFFSET


def ISNONTERMINAL(x):
return x >= NT_OFFSET


def ISEOF(x):
return x == ENDMARKER

0 comments on commit 9a2ea00

Please sign in to comment.