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

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

Merged
merged 1 commit into from Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion sanic/__version__.py
@@ -1 +1 @@
__version__ = "20.12.5"
__version__ = "20.12.6"
13 changes: 13 additions & 0 deletions sanic/app.py
Expand Up @@ -2,6 +2,7 @@
import logging.config
import os
import re
import sys

from asyncio import CancelledError, Protocol, ensure_future, get_event_loop
from collections import defaultdict, deque
Expand Down Expand Up @@ -65,6 +66,18 @@ def __init__(
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)
Expand Down
6 changes: 5 additions & 1 deletion sanic/server.py
Expand Up @@ -169,7 +169,11 @@ def __init__(
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
Expand Down