MCPcopy Index your code
hub / github.com/python/cpython / is_other_python_frame

Method is_other_python_frame

Tools/gdb/libpython.py:1791–1842  ·  view source on GitHub ↗

Is this frame worth displaying in python backtraces? Examples: - waiting on the GIL - garbage-collecting - within a CFunction If it is, return a descriptive string For other frames, return False

(self)

Source from the content-addressed store, hash-verified

1789 return False
1790
1791 def is_other_python_frame(self):
1792 '''Is this frame worth displaying in python backtraces?
1793 Examples:
1794 - waiting on the GIL
1795 - garbage-collecting
1796 - within a CFunction
1797 If it is, return a descriptive string
1798 For other frames, return False
1799 '''
1800 if self.is_waiting_for_gil():
1801 return 'Waiting for the GIL'
1802
1803 if self.is_gc_collect():
1804 return 'Garbage-collecting'
1805
1806 # Detect invocations of PyCFunction instances:
1807 frame = self._gdbframe
1808 caller = frame.name()
1809 if not caller:
1810 return False
1811
1812 if (caller.startswith('cfunction_vectorcall_') or
1813 caller == 'cfunction_call'):
1814 arg_name = 'func'
1815 # Within that frame:
1816 # "func" is the local containing the PyObject* of the
1817 # PyCFunctionObject instance
1818 # "f" is the same value, but cast to (PyCFunctionObject*)
1819 # "self" is the (PyObject*) of the 'self'
1820 try:
1821 # Use the prettyprinter for the func:
1822 func = frame.read_var(arg_name)
1823 return str(func)
1824 except ValueError:
1825 return ('PyCFunction invocation (unable to read %s: '
1826 'missing debuginfos?)' % arg_name)
1827 except RuntimeError:
1828 return 'PyCFunction invocation (unable to read %s)' % arg_name
1829
1830 if caller == 'wrapper_call':
1831 arg_name = 'wp'
1832 try:
1833 func = frame.read_var(arg_name)
1834 return str(func)
1835 except ValueError:
1836 return ('<wrapper_call invocation (unable to read %s: '
1837 'missing debuginfos?)>' % arg_name)
1838 except RuntimeError:
1839 return '<wrapper_call invocation (unable to read %s)>' % arg_name
1840
1841 # This frame isn't worth reporting:
1842 return False
1843
1844 def is_waiting_for_gil(self):
1845 '''Is this frame waiting on the GIL?'''

Callers 3

is_python_frameMethod · 0.95
print_summaryMethod · 0.95
print_traceback_helperFunction · 0.80

Calls 5

is_waiting_for_gilMethod · 0.95
is_gc_collectMethod · 0.95
strFunction · 0.85
nameMethod · 0.45
startswithMethod · 0.45

Tested by

no test coverage detected