mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-13 07:47:14 +03:00
Fix logging from mangled methods where class name starts with "_"
Python's name-mangling rules are quite complex. Previously, EDMC was incorrectly mangling names where the class name starts with one or more underscores; if the class name starts with any underscores, they should be removed before prepending to the identifier being mangled. If the class name contains *only* underscores, no mangling should be performed.
This commit is contained in:
parent
5776149d5d
commit
590cd608d3
@ -309,9 +309,11 @@ class EDMCContextFilter(logging.Filter):
|
||||
|
||||
if frame_class:
|
||||
# See https://en.wikipedia.org/wiki/Name_mangling#Python for how name mangling works.
|
||||
# For more detail, see _Py_Mangle in CPython's Python/compile.c.
|
||||
name = frame_info.function
|
||||
if name.startswith("__") and not name.endswith("__"):
|
||||
name = f'_{frame_class.__class__.__name__}{frame_info.function}'
|
||||
class_name = frame_class.__class__.__name__.lstrip("_")
|
||||
if name.startswith("__") and not name.endswith("__") and class_name:
|
||||
name = f'_{class_name}{frame_info.function}'
|
||||
|
||||
# Find __qualname__ of the caller
|
||||
fn = inspect.getattr_static(frame_class, name, None)
|
||||
|
Loading…
x
Reference in New Issue
Block a user