Avoid fetching logger in check_if_deprecated_constant if there is nothing to log (#107341)
getLogger needs a threading lock so its nice to avoid calling it if we are not going to log anythingpull/107357/head
parent
851ad21d11
commit
6ff990e2c2
|
@ -252,7 +252,6 @@ def check_if_deprecated_constant(name: str, module_globals: dict[str, Any]) -> A
|
|||
Otherwise raise AttributeError.
|
||||
"""
|
||||
module_name = module_globals.get("__name__")
|
||||
logger = logging.getLogger(module_name)
|
||||
value = replacement = None
|
||||
if (deprecated_const := module_globals.get(_PREFIX_DEPRECATED + name)) is None:
|
||||
raise AttributeError(f"Module {module_name!r} has no attribute {name!r}")
|
||||
|
@ -273,7 +272,7 @@ def check_if_deprecated_constant(name: str, module_globals: dict[str, Any]) -> A
|
|||
"but an instance of DeprecatedConstant or DeprecatedConstantEnum is required"
|
||||
)
|
||||
|
||||
logger.debug(msg)
|
||||
logging.getLogger(module_name).debug(msg)
|
||||
# PEP 562 -- Module __getattr__ and __dir__
|
||||
# specifies that __getattr__ should raise AttributeError if the attribute is not
|
||||
# found.
|
||||
|
|
Loading…
Reference in New Issue