MCPcopy Create free account
hub / github.com/ipython/ipython / validate_stb

Method validate_stb

IPython/core/interactiveshell.py:1884–1905  ·  view source on GitHub ↗

validate structured traceback return type return type of CustomTB *should* be a list of strings, but allow single strings or None, which are harmless. This function will *always* return a list of strings, and will raise a Type

(stb)

Source from the content-addressed store, hash-verified

1882 print('Traceback :', tb)
1883
1884 def validate_stb(stb):
1885 """validate structured traceback return type
1886
1887 return type of CustomTB *should* be a list of strings, but allow
1888 single strings or None, which are harmless.
1889
1890 This function will *always* return a list of strings,
1891 and will raise a TypeError if stb is inappropriate.
1892 """
1893 msg = "CustomTB must return list of strings, not %r" % stb
1894 if stb is None:
1895 return []
1896 elif isinstance(stb, str):
1897 return [stb]
1898 elif not isinstance(stb, list):
1899 raise TypeError(msg)
1900 # it's a list
1901 for line in stb:
1902 # check every element
1903 if not isinstance(line, str):
1904 raise TypeError(msg)
1905 return stb
1906
1907 if handler is None:
1908 wrapped = dummy_handler

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected