You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Private name mangling: When an identifier that textually occurs in a class definition begins with two or more underscore characters and does not end in two or more underscores, it is considered a private name of that class. Private names are transformed to a longer form before code is generated for them. The transformation inserts the class name, with leading underscores removed and a single underscore inserted, in front of the name. For example, the identifier __spam occurring in a class named Ham will be transformed to _Ham__spam. This transformation is independent of the syntactical context in which the identifier is used. If the transformed name is extremely long (longer than 255 characters), implementation defined truncation may happen. If the class name consists only of underscores, no transformation is done.
Recompiles `source_fn` so that essentially every node of its AST tree is wrapped by a call to `transform_fn` with the evaluated value along with context information about the source code.
249
266
"""
250
267
try:
251
-
source=inspect.getsource(source_fn)
268
+
original_source=inspect.getsource(source_fn)
252
269
253
-
# nested functions have excess indentation preventing compile; inspect.cleandoc(source) is an alternative
254
-
source=dedent(source)
270
+
# nested functions have excess indentation preventing compile; inspect.cleandoc(source) is an alternative but less reliable
# a decorator doesn't actually have to return a function! (could be used solely for side effect) e.g. `@register_backend_lookup_factory` for `find_content_backend` in `awkward/contents/content.py`
437
+
ifnotcallable(transformed_fn):
438
+
returnErr(
439
+
f"Resulting transform of definition of {get_fn_name(source_fn)} is not even callable (got {transform_fn}). Perhaps a decorator that returns None?"
440
+
)
441
+
415
442
# unmangle the name again - it's possible some packages might use __name__ internally for registries and whatnot
0 commit comments