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

#11857 test on py 3.12rc #11910

Merged
merged 27 commits into from Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8799b53
replace utcfromtimezone with fromtimezone(x, utc).replace(tzinfo=None)
graingert Aug 16, 2023
dd1a3fa
add newsfragment
graingert Aug 16, 2023
aec69ad
test on 3.12
graingert Aug 16, 2023
084d956
add newsfragment
graingert Aug 16, 2023
58b7117
asyncio.iscoroutine no longer accepts generators on 3.12
graingert Aug 16, 2023
f8390e3
tokenize no longer accepts \0 bytes in source code in 3.12
graingert Aug 16, 2023
d8edf4c
tempfile.mkdtemp() always returns absolute paths in 3.12
graingert Aug 16, 2023
7b9d4d9
work around builtins.sum accurancy increase on 3.12
graingert Aug 16, 2023
4cf97c5
Update src/twisted/internet/defer.py
graingert Aug 16, 2023
e903eea
Update src/twisted/persisted/aot.py
graingert Aug 16, 2023
c65da07
add py311 and py312 trove classifiers
graingert Aug 16, 2023
1c67617
Revert "Update src/twisted/persisted/aot.py"
graingert Aug 16, 2023
3b3fa36
Revert "tokenize no longer accepts \0 bytes in source code in 3.12"
graingert Aug 16, 2023
d1760b1
vendor tokenize and token for py3.12
graingert Aug 16, 2023
07bd957
fix __all__ and apply pre-commit
graingert Aug 16, 2023
f86129f
flake8 _tokenize
graingert Aug 16, 2023
c261159
Update src/twisted/persisted/aot.py
graingert Aug 16, 2023
985e695
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 16, 2023
2ed22ac
fix _tokenize mypy
graingert Aug 16, 2023
dbb48d6
fix tokenize on py3.7
graingert Aug 16, 2023
c710f0b
warn about _tokenize re aot
graingert Aug 16, 2023
6610c4f
Update src/twisted/test/test_task.py
graingert Aug 16, 2023
2eb25e7
Update test_task.py
graingert Aug 16, 2023
e38335d
Update src/twisted/trial/_synctest.py
graingert Aug 16, 2023
592574e
Update src/twisted/test/test_persisted.py
graingert Aug 16, 2023
13270eb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 16, 2023
61cae87
fix testIndentify
graingert Aug 16, 2023
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
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
6 changes: 4 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,9 @@ 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
graingert marked this conversation as resolved.
Show resolved Hide resolved
if iscoroutine(coro) or inspect.isgenerator(coro):
Copy link
Member

Choose a reason for hiding this comment

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

I don't have experince with coroutine.

I don't understand this comment. Sorry

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.
6 changes: 5 additions & 1 deletion src/twisted/persisted/aot.py
Expand Up @@ -231,13 +231,17 @@ def indentify(s):
out = []
stack = []
l = ["", s]

def readline():
return l.pop().replace("\0", "")
graingert marked this conversation as resolved.
Show resolved Hide resolved

for (
tokenType,
tokenString,
(startRow, startColumn),
(endRow, endColumn),
logicalLine,
) in tokenize(l.pop):
) in tokenize(readline):
if tokenString in ["[", "(", "{"]:
stack.append(tokenString)
elif tokenString in ["]", ")", "}"]:
Expand Down
13 changes: 9 additions & 4 deletions src/twisted/python/_tzhelper.py
Expand Up @@ -6,7 +6,12 @@
Time zone utilities.
"""

from datetime import datetime as DateTime, timedelta as TimeDelta, tzinfo as TZInfo
from datetime import (
datetime as DateTime,
timedelta as TimeDelta,
timezone,
tzinfo as TZInfo,
)
from typing import Optional

__all__ = [
Expand Down Expand Up @@ -68,9 +73,9 @@ def fromLocalTimeStamp(cls, timeStamp: float) -> "FixedOffsetTimeZone":
Create a time zone with a fixed offset corresponding to a time stamp in
the system's locally configured time zone.
"""
offset = DateTime.fromtimestamp(timeStamp) - DateTime.utcfromtimestamp(
timeStamp
)
offset = DateTime.fromtimestamp(timeStamp) - DateTime.fromtimestamp(
timeStamp, timezone.utc
).replace(tzinfo=None)
return cls(offset)

def utcoffset(self, dt: Optional[DateTime]) -> TimeDelta:
Expand Down
10 changes: 7 additions & 3 deletions src/twisted/python/log.py
Expand Up @@ -11,7 +11,7 @@
import time
import warnings
from abc import ABC, abstractmethod
from datetime import datetime
from datetime import datetime, timezone
from typing import Any, BinaryIO, Dict, Optional, cast

from zope.interface import Interface
Expand Down Expand Up @@ -490,7 +490,9 @@ def getTimezoneOffset(self, when):
@return: The number of seconds offset from UTC. West is positive,
east is negative.
"""
offset = datetime.utcfromtimestamp(when) - datetime.fromtimestamp(when)
offset = datetime.fromtimestamp(when, timezone.utc).replace(
tzinfo=None
) - datetime.fromtimestamp(when)
return offset.days * (60 * 60 * 24) + offset.seconds

def formatTime(self, when):
Expand All @@ -512,7 +514,9 @@ def formatTime(self, when):
return datetime.fromtimestamp(when).strftime(self.timeFormat)

tzOffset = -self.getTimezoneOffset(when)
when = datetime.utcfromtimestamp(when + tzOffset)
when = datetime.fromtimestamp(when + tzOffset, timezone.utc).replace(
tzinfo=None
)
tzHour = abs(int(tzOffset / 60 / 60))
tzMin = abs(int(tzOffset / 60 % 60))
if tzOffset < 0:
Expand Down
7 changes: 7 additions & 0 deletions src/twisted/test/test_task.py
Expand Up @@ -467,6 +467,13 @@ def test_withCountFloatingPointBoundary(self):
for x in range(count):
clock.advance(interval)

# work around https://github.com/python/cpython/issues/100425 on py312
def sum(items):
total = 0.0
graingert marked this conversation as resolved.
Show resolved Hide resolved
for item in items:
total += item
return total

# There is still an epsilon of inaccuracy here; 0.1 is not quite
# exactly 1/10 in binary, so we need to push our clock over the
# threshold.
Expand Down
3 changes: 2 additions & 1 deletion src/twisted/trial/_synctest.py
Expand Up @@ -1328,7 +1328,8 @@ def mktemp(self):
)
if not os.path.exists(base):
os.makedirs(base)
dirname = tempfile.mkdtemp("", "", base)
# workaround https://github.com/python/cpython/issues/51574
dirname = os.path.relpath(tempfile.mkdtemp("", "", base))
graingert marked this conversation as resolved.
Show resolved Hide resolved
return os.path.join(dirname, "temp")

def _getSuppress(self):
Expand Down