72 lines
2.6 KiB
Diff
72 lines
2.6 KiB
Diff
|
|
From a5590bb04de3f1f201fd1fd0ce9cfe5825db80ac Mon Sep 17 00:00:00 2001
|
||
|
|
From: =?UTF-8?q?=E6=BB=95=E7=A3=8A?= Hugo van Kemenade
|
||
|
|
Date: Thu, 9 May 2024 14:35:57 +0800
|
||
|
|
Subject: [PATCH] Add support for Python 3.12
|
||
|
|
|
||
|
|
---
|
||
|
|
README.rst | 2 +-
|
||
|
|
curio/channel.py | 14 ++++++++++----
|
||
|
|
curio/ssl.py | 4 ++--
|
||
|
|
3 files changed, 13 insertions(+), 7 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/README.rst b/README.rst
|
||
|
|
index 945dac8..83f9ee7 100644
|
||
|
|
--- a/README.rst
|
||
|
|
+++ b/README.rst
|
||
|
|
@@ -3,7 +3,7 @@ Curio
|
||
|
|
|
||
|
|
Curio is a coroutine-based library for concurrent Python systems
|
||
|
|
programming using async/await. It provides standard programming
|
||
|
|
-abstractions such as as tasks, sockets, files, locks, and queues as
|
||
|
|
+abstractions such as tasks, sockets, files, locks, and queues as
|
||
|
|
well as some advanced features such as support for structured
|
||
|
|
concurrency. It works on Unix and Windows and has zero dependencies.
|
||
|
|
You'll find it to be familiar, small, fast, and fun.
|
||
|
|
diff --git a/curio/channel.py b/curio/channel.py
|
||
|
|
index 230427f..556be63 100644
|
||
|
|
--- a/curio/channel.py
|
||
|
|
+++ b/curio/channel.py
|
||
|
|
@@ -28,10 +28,16 @@ from .time import timeout_after, sleep
|
||
|
|
# Authentication parameters (copied from multiprocessing)
|
||
|
|
|
||
|
|
AUTH_MESSAGE_LENGTH = mpc.MESSAGE_LENGTH # 20
|
||
|
|
-CHALLENGE = mpc.CHALLENGE # b'#CHALLENGE#'
|
||
|
|
-WELCOME = mpc.WELCOME # b'#WELCOME#'
|
||
|
|
-FAILURE = mpc.FAILURE # b'#FAILURE#'
|
||
|
|
-
|
||
|
|
+try:
|
||
|
|
+ # Python 3.12+
|
||
|
|
+ CHALLENGE = mpc._CHALLENGE # b'#CHALLENGE#'
|
||
|
|
+ WELCOME = mpc._WELCOME # b'#WELCOME#'
|
||
|
|
+ FAILURE = mpc._FAILURE # b'#FAILURE#'
|
||
|
|
+except AttributeError:
|
||
|
|
+ # Python 3.7-3.11
|
||
|
|
+ CHALLENGE = mpc.CHALLENGE # b'#CHALLENGE#'
|
||
|
|
+ WELCOME = mpc.WELCOME # b'#WELCOME#'
|
||
|
|
+ FAILURE = mpc.FAILURE # b'#FAILURE#'
|
||
|
|
|
||
|
|
|
||
|
|
class ConnectionError(CurioError):
|
||
|
|
diff --git a/curio/ssl.py b/curio/ssl.py
|
||
|
|
index 37efa08..4619eb1 100644
|
||
|
|
--- a/curio/ssl.py
|
||
|
|
+++ b/curio/ssl.py
|
||
|
|
@@ -27,12 +27,12 @@ from .workers import run_in_thread
|
||
|
|
from .io import Socket
|
||
|
|
|
||
|
|
if _ssl:
|
||
|
|
- @wraps(_ssl.wrap_socket)
|
||
|
|
+ @wraps(_ssl.SSLContext.wrap_socket)
|
||
|
|
async def wrap_socket(sock, *args, do_handshake_on_connect=True, **kwargs):
|
||
|
|
if isinstance(sock, Socket):
|
||
|
|
sock = sock._socket
|
||
|
|
|
||
|
|
- ssl_sock = _ssl.wrap_socket(sock, *args, do_handshake_on_connect=False, **kwargs)
|
||
|
|
+ ssl_sock = _ssl.SSLContext.wrap_socket(sock, *args, do_handshake_on_connect=False, **kwargs)
|
||
|
|
cssl_sock = Socket(ssl_sock)
|
||
|
|
cssl_sock.do_handshake_on_connect = do_handshake_on_connect
|
||
|
|
if do_handshake_on_connect and ssl_sock._connected:
|
||
|
|
--
|
||
|
|
2.43.0
|
||
|
|
|