Skip to content

Commit 34e7024

Browse files
authored
Check for ExceptionMiddlware removal in starlette.exceptions (#1282)
* Add check for import proxy removal * Fix order of logic
1 parent 4c06d26 commit 34e7024

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

newrelic/hooks/framework_starlette.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@ def instrument_starlette_middleware_exceptions(module):
252252
def instrument_starlette_exceptions(module):
253253
# ExceptionMiddleware was moved to starlette.middleware.exceptions, need to check
254254
# that it isn't being imported through a deprecation and double wrapped.
255-
if not hasattr(module, "__deprecated__"):
255+
256+
# After v0.45.0, the import proxy for ExceptionMiddleware was removed from starlette.exceptions
257+
if not hasattr(module, "__deprecated__") and hasattr(module, "ExceptionMiddleware"):
256258

257259
wrap_function_wrapper(module, "ExceptionMiddleware.__call__", error_middleware_wrapper)
258260

0 commit comments

Comments
 (0)