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 response
|
||||||
|
|
||||||
return None
|
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.
|
# ... and with the hosts in REALM_HOSTS.
|
||||||
ALLOWED_HOSTS += REALM_HOSTS.values()
|
ALLOWED_HOSTS += REALM_HOSTS.values()
|
||||||
|
|
||||||
MIDDLEWARE = (
|
MIDDLEWARE = [
|
||||||
"zerver.middleware.TagRequests",
|
"zerver.middleware.TagRequests",
|
||||||
"zerver.middleware.SetRemoteAddrFromRealIpHeader",
|
"zerver.middleware.SetRemoteAddrFromRealIpHeader",
|
||||||
"zerver.middleware.RequestContext",
|
"zerver.middleware.RequestContext",
|
||||||
|
@ -182,7 +182,7 @@ MIDDLEWARE = (
|
||||||
"two_factor.middleware.threadlocals.ThreadLocals", # Required by Twilio
|
"two_factor.middleware.threadlocals.ThreadLocals", # Required by Twilio
|
||||||
# Needs to be after CommonMiddleware, which sets Content-Length
|
# Needs to be after CommonMiddleware, which sets Content-Length
|
||||||
"zerver.middleware.FinalizeOpenGraphDescription",
|
"zerver.middleware.FinalizeOpenGraphDescription",
|
||||||
)
|
]
|
||||||
|
|
||||||
AUTH_USER_MODEL = "zerver.UserProfile"
|
AUTH_USER_MODEL = "zerver.UserProfile"
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ from .settings import (
|
||||||
EXTERNAL_HOST,
|
EXTERNAL_HOST,
|
||||||
LOCAL_DATABASE_PASSWORD,
|
LOCAL_DATABASE_PASSWORD,
|
||||||
LOGGING,
|
LOGGING,
|
||||||
|
MIDDLEWARE,
|
||||||
)
|
)
|
||||||
|
|
||||||
FULL_STACK_ZULIP_TEST = "FULL_STACK_ZULIP_TEST" in os.environ
|
FULL_STACK_ZULIP_TEST = "FULL_STACK_ZULIP_TEST" in os.environ
|
||||||
|
@ -269,3 +270,13 @@ SCIM_CONFIG: Dict[str, SCIMConfigDict] = {
|
||||||
"name_formatted_included": True,
|
"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