module pycode.trace_execution

Inheritance diagram of pyquickhelper.pycode.trace_execution

Short summary

module pyquickhelper.pycode.trace_execution

Various function to help investigate an error.

source on GitHub

Classes

class

truncated documentation

ErrorOnPurpose

raise to get the call stack

Functions

function

truncated documentation

get_call_stack

Returns a string showing the call stack when this function is called.

Documentation

Various function to help investigate an error.

source on GitHub

exception pyquickhelper.pycode.trace_execution.ErrorOnPurpose[source]

Bases: Exception

raise to get the call stack

source on GitHub

pyquickhelper.pycode.trace_execution.get_call_stack()[source]

Returns a string showing the call stack when this function is called.

Display the call stack

<<<

from pyquickhelper.pycode import get_call_stack
print(get_call_stack())

>>>

      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/src/pyquickhelper/helpgen/process_sphinx_cmd.py", line 23, in <module>
        main()
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/src/pyquickhelper/helpgen/process_sphinx_cmd.py", line 19, in main
        run_sphinx_build(sys.argv)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/src/pyquickhelper/helpgen/process_sphinx_cmd.py", line 15, in run_sphinx_build
        build_main(argv=argv[1:])
      File "/usr/local/lib/python3.9/site-packages/sphinx/cmd/build.py", line 293, in main
        return build_main(argv)
      File "/usr/local/lib/python3.9/site-packages/sphinx/cmd/build.py", line 279, in build_main
        app.build(args.force_all, filenames)
      File "/usr/local/lib/python3.9/site-packages/sphinx/application.py", line 350, in build
        self.builder.build_update()
      File "/usr/local/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 302, in build_update
        self.build(to_build,
      File "/usr/local/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 318, in build
        updated_docnames = set(self.read())
      File "/usr/local/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 425, in read
        self._read_serial(docnames)
      File "/usr/local/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 446, in _read_serial
        self.read_doc(docname)
      File "/usr/local/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 502, in read_doc
        publisher.publish()
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/core.py", line 217, in publish
        self.document = self.reader.read(self.source, self.parser,
      File "/usr/local/lib/python3.9/site-packages/sphinx/io.py", line 104, in read
        self.parse()
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/readers/__init__.py", line 78, in parse
        self.parser.parse(self.input, document)
      File "/usr/local/lib/python3.9/site-packages/sphinx/parsers.py", line 78, in parse
        self.statemachine.run(inputlines, document, inliner=self.inliner)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 170, in run
        results = StateMachineWS.run(self, input_lines, input_offset,
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/statemachine.py", line 239, in run
        context, next_state, result = self.check_line(
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/statemachine.py", line 451, in check_line
        return method(match, context, next_state)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2769, in underline
        self.section(title, source, style, lineno - 1, messages)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 327, in section
        self.new_subsection(title, lineno, messages)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 393, in new_subsection
        newabsoffset = self.nested_parse(
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
        state_machine.run(block, input_offset, memo=self.memo,
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 196, in run
        results = StateMachineWS.run(self, input_lines, input_offset)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/statemachine.py", line 239, in run
        context, next_state, result = self.check_line(
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/statemachine.py", line 451, in check_line
        return method(match, context, next_state)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2769, in underline
        self.section(title, source, style, lineno - 1, messages)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 327, in section
        self.new_subsection(title, lineno, messages)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 393, in new_subsection
        newabsoffset = self.nested_parse(
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
        state_machine.run(block, input_offset, memo=self.memo,
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 196, in run
        results = StateMachineWS.run(self, input_lines, input_offset)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/statemachine.py", line 239, in run
        context, next_state, result = self.check_line(
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/statemachine.py", line 451, in check_line
        return method(match, context, next_state)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2342, in explicit_markup
        nodelist, blank_finish = self.explicit_construct(match)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2354, in explicit_construct
        return method(self, expmatch)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2096, in directive
        return self.run_directive(
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2146, in run_directive
        result = directive_instance.run()
      File "/usr/local/lib/python3.9/site-packages/sphinx/ext/autodoc/directive.py", line 159, in run
        result = parse_generated_content(self.state, params.result, documenter)
      File "/usr/local/lib/python3.9/site-packages/sphinx/ext/autodoc/directive.py", line 102, in parse_generated_content
        nested_parse_with_titles(state, content, node)
      File "/usr/local/lib/python3.9/site-packages/sphinx/util/nodes.py", line 340, in nested_parse_with_titles
        return state.nested_parse(content, 0, node, match_titles=1)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
        state_machine.run(block, input_offset, memo=self.memo,
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 196, in run
        results = StateMachineWS.run(self, input_lines, input_offset)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/statemachine.py", line 239, in run
        context, next_state, result = self.check_line(
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/statemachine.py", line 451, in check_line
        return method(match, context, next_state)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2344, in explicit_markup
        self.explicit_list(blank_finish)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2369, in explicit_list
        newline_offset, blank_finish = self.nested_list_parse(
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 318, in nested_list_parse
        state_machine.run(block, input_offset, memo=self.memo,
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 196, in run
        results = StateMachineWS.run(self, input_lines, input_offset)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/statemachine.py", line 239, in run
        context, next_state, result = self.check_line(
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/statemachine.py", line 451, in check_line
        return method(match, context, next_state)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2647, in explicit_markup
        nodelist, blank_finish = self.explicit_construct(match)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2354, in explicit_construct
        return method(self, expmatch)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2096, in directive
        return self.run_directive(
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2146, in run_directive
        result = directive_instance.run()
      File "/usr/local/lib/python3.9/site-packages/sphinx/domains/__init__.py", line 281, in run
        return super().run()
      File "/usr/local/lib/python3.9/site-packages/sphinx/directives/__init__.py", line 262, in run
        self.state.nested_parse(self.content, self.content_offset, contentnode)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
        state_machine.run(block, input_offset, memo=self.memo,
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 196, in run
        results = StateMachineWS.run(self, input_lines, input_offset)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/statemachine.py", line 239, in run
        context, next_state, result = self.check_line(
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/statemachine.py", line 451, in check_line
        return method(match, context, next_state)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2342, in explicit_markup
        nodelist, blank_finish = self.explicit_construct(match)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2354, in explicit_construct
        return method(self, expmatch)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2096, in directive
        return self.run_directive(
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2146, in run_directive
        result = directive_instance.run()
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_doc/sphinxdoc/source/pyquickhelper/sphinxext/sphinx_exref_extension.py", line 100, in run
        return BlocRef.run(self)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_doc/sphinxdoc/source/pyquickhelper/sphinxext/sphinx_blocref_extension.py", line 137, in run
        return self.private_run()
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_doc/sphinxdoc/source/pyquickhelper/sphinxext/sphinx_blocref_extension.py", line 165, in private_run
        (blocref,) = super(BlocRef, self).run()
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/directives/admonitions.py", line 46, in run
        self.state.nested_parse(self.content, self.content_offset,
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
        state_machine.run(block, input_offset, memo=self.memo,
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 196, in run
        results = StateMachineWS.run(self, input_lines, input_offset)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/statemachine.py", line 239, in run
        context, next_state, result = self.check_line(
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/statemachine.py", line 451, in check_line
        return method(match, context, next_state)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2342, in explicit_markup
        nodelist, blank_finish = self.explicit_construct(match)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2354, in explicit_construct
        return method(self, expmatch)
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2096, in directive
        return self.run_directive(
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_venv/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2146, in run_directive
        result = directive_instance.run()
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_doc/sphinxdoc/source/pyquickhelper/sphinxext/sphinx_runpython_extension.py", line 589, in run
        out, err, context = run_python_script(script, comment=comment, setsysvar=p['setsysvar'],
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_doc/sphinxdoc/source/pyquickhelper/sphinxext/sphinx_runpython_extension.py", line 242, in run_python_script
        exec(obj, globs, loc)
      File "", line 5, in <module>
      File "", line 4, in run_python_script_139809772963008
      File "somewhere/workspace/pyquickhelper/pyquickhelper_UT_39_std/_doc/sphinxdoc/source/pyquickhelper/pycode/trace_execution.py", line 39, in get_call_stack
        traceback.print_stack(file=s)

source on GitHub