[libcxx-commits] [PATCH] D71136: [libcxx] Replace func_name with __name__ for compatibility with Python 3

Sergej Jaskiewicz via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Dec 6 11:28:02 PST 2019

broadwaylamb created this revision.
broadwaylamb added a reviewer: jroelofs.
Herald added a reviewer: EricWF.
Herald added subscribers: libcxx-commits, ldionne, christof.
Herald added a project: libc++.
broadwaylamb updated this revision to Diff 232619.
broadwaylamb added a comment.
Herald added a reviewer: mclow.lists.
broadwaylamb edited the summary of this revision.

Replace one more `func_name`

The `__name__` attribute is the correct way to get a function name in
Python 3. This also works with Python 2.

  rG LLVM Github Monorepo



Index: libcxx/utils/libcxx/test/tracing.py
--- libcxx/utils/libcxx/test/tracing.py
+++ libcxx/utils/libcxx/test/tracing.py
@@ -14,7 +14,7 @@
     def wrapper(*args, **kwargs):
         kwarg_strs = ['{}={}'.format(k, v) for (k, v) in kwargs]
         arg_str = ', '.join([str(a) for a in args] + kwarg_strs)
-        call_str = '{}({})'.format(function.func_name, arg_str)
+        call_str = '{}({})'.format(function.__name__, arg_str)
         # Perform the call itself, logging before, after, and anything thrown.
@@ -36,7 +36,7 @@
     for name, member in inspect.getmembers(obj):
         if inspect.ismethod(member):
             # Skip meta-functions, decorate everything else
-            if not member.func_name.startswith('__'):
+            if not member.__name__.startswith('__'):
                 setattr(obj, name, trace_function(member, log_calls,
                                                   log_results, label))
     return obj

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71136.232619.patch
Type: text/x-patch
Size: 1035 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20191206/918b3004/attachment.bin>

More information about the libcxx-commits mailing list