mirror of https://github.com/zulip/zulip.git
zproject: Prevent having exactly 17/18 middlewares, for Python 3.11 bug.
Having exactly 17 or 18 middlewares, on Python 3.11.0 and above, causes python to segfault when running tests with coverage; see https://github.com/python/cpython/issues/106092 Work around this by adding one or two no-op middlewares if we would hit those unlucky numbers. We only add them in testing, since coverage is a requirement to trigger it, and there is no reason to burden production with additional wrapping.
This commit is contained in:
parent
671b708c4b
commit
cf0b803d50
|
@ -689,3 +689,7 @@ class ZulipSCIMAuthCheckMiddleware(SCIMAuthCheckMiddleware):
|
|||
return response
|
||||
|
||||
return None
|
||||
|
||||
|
||||
class ZulipNoopMiddleware(MiddlewareMixin):
|
||||
pass
|
||||
|
|
|
@ -159,7 +159,7 @@ ALLOWED_HOSTS += [EXTERNAL_HOST_WITHOUT_PORT, "." + EXTERNAL_HOST_WITHOUT_PORT]
|
|||
# ... and with the hosts in REALM_HOSTS.
|
||||
ALLOWED_HOSTS += REALM_HOSTS.values()
|
||||
|
||||
MIDDLEWARE = (
|
||||
MIDDLEWARE = [
|
||||
"zerver.middleware.TagRequests",
|
||||
"zerver.middleware.SetRemoteAddrFromRealIpHeader",
|
||||
"zerver.middleware.RequestContext",
|
||||
|
@ -182,7 +182,7 @@ MIDDLEWARE = (
|
|||
"two_factor.middleware.threadlocals.ThreadLocals", # Required by Twilio
|
||||
# Needs to be after CommonMiddleware, which sets Content-Length
|
||||
"zerver.middleware.FinalizeOpenGraphDescription",
|
||||
)
|
||||
]
|
||||
|
||||
AUTH_USER_MODEL = "zerver.UserProfile"
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ from .settings import (
|
|||
EXTERNAL_HOST,
|
||||
LOCAL_DATABASE_PASSWORD,
|
||||
LOGGING,
|
||||
MIDDLEWARE,
|
||||
)
|
||||
|
||||
FULL_STACK_ZULIP_TEST = "FULL_STACK_ZULIP_TEST" in os.environ
|
||||
|
@ -269,3 +270,13 @@ SCIM_CONFIG: Dict[str, SCIMConfigDict] = {
|
|||
"name_formatted_included": True,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
while len(MIDDLEWARE) < 19:
|
||||
# The following middleware serves to skip having exactly 17 or 18
|
||||
# middlewares, which can segfault Python 3.11 when running with
|
||||
# coverage enabled; see
|
||||
# https://github.com/python/cpython/issues/106092
|
||||
MIDDLEWARE += [
|
||||
"zerver.middleware.ZulipNoopMiddleware",
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue