Skip to content

Commit

Permalink
Potential server crash if running Python 3.10 w/ Sanic 20.12 (#2400)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahopkins authored Feb 16, 2022
1 parent 6e55e73 commit 3b85b3b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sanic/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "20.12.5"
__version__ = "20.12.6"
13 changes: 13 additions & 0 deletions sanic/app.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 3b85b3b

Please sign in to comment.