Potential server crash if running Python 3.10 w/ Sanic 20.12 (#2400)

This commit is contained in:
Adam Hopkins 2022-02-16 18:03:05 +02:00 committed by GitHub
parent 6e55e73da1
commit 3b85b3bbad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 2 deletions

View File

@ -1 +1 @@
__version__ = "20.12.5"
__version__ = "20.12.6"

View File

@ -2,6 +2,7 @@ import logging
import logging.config
import os
import re
import sys
from asyncio import CancelledError, Protocol, ensure_future, get_event_loop
from collections import defaultdict, deque
@ -65,6 +66,18 @@ class Sanic:
if configure_logging:
logging.config.dictConfig(log_config or LOGGING_CONFIG_DEFAULTS)
if sys.version_info >= (3, 10):
error_logger.error(
"Unsupported version of Python has been detected.\n\nPython "
f"version {sys.version} is not supported by this version of "
"Sanic. There is a security advisory that has been issued for "
"Sanic v20.12 while running Python 3.10+. You should either "
"use a supported version of Python (v3.6 - v3.9) or upgrade "
"Sanic to v21+.\n\nPlease see https://github.com/sanic-org/"
"sanic/security/advisories/GHSA-7p79-6x2v-5h88 for "
"more information.\n"
)
self.name = name
self.asgi = False
self.router = router or Router(self)

View File

@ -169,7 +169,11 @@ class HttpProtocol(asyncio.Protocol):
self.request_class = self.app.request_class or Request
self.is_request_stream = self.app.is_request_stream
self._is_stream_handler = False
self._not_paused = asyncio.Event(loop=deprecated_loop)
self._not_paused = (
asyncio.Event()
if sys.version_info >= (3, 10)
else asyncio.Event(loop=deprecated_loop)
)
self._total_request_size = 0
self._request_timeout_handler = None
self._response_timeout_handler = None