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

Method __init__

IPython/core/debugger.py:203–283  ·  view source on GitHub ↗

Create a new IPython debugger. :param color_scheme: Deprecated, do not use. :param completekey: Passed to pdb.Pdb. :param stdin: Passed to pdb.Pdb. :param stdout: Passed to pdb.Pdb. :param context: Number of lines of source code context to show when

(self, color_scheme=None, completekey=None,
                 stdin=None, stdout=None, context=5, **kwargs)

Source from the content-addressed store, hash-verified

201 """
202
203 def __init__(self, color_scheme=None, completekey=None,
204 stdin=None, stdout=None, context=5, **kwargs):
205 """Create a new IPython debugger.
206
207 :param color_scheme: Deprecated, do not use.
208 :param completekey: Passed to pdb.Pdb.
209 :param stdin: Passed to pdb.Pdb.
210 :param stdout: Passed to pdb.Pdb.
211 :param context: Number of lines of source code context to show when
212 displaying stacktrace information.
213 :param kwargs: Passed to pdb.Pdb.
214 The possibilities are python version dependent, see the python
215 docs for more info.
216 """
217
218 # Parent constructor:
219 try:
220 self.context = int(context)
221 if self.context <= 0:
222 raise ValueError("Context must be a positive integer")
223 except (TypeError, ValueError):
224 raise ValueError("Context must be a positive integer")
225
226 # `kwargs` ensures full compatibility with stdlib's `pdb.Pdb`.
227 OldPdb.__init__(self, completekey, stdin, stdout, **kwargs)
228
229 # IPython changes...
230 self.shell = get_ipython()
231
232 if self.shell is None:
233 save_main = sys.modules['__main__']
234 # No IPython instance running, we must create one
235 from IPython.terminal.interactiveshell import \
236 TerminalInteractiveShell
237 self.shell = TerminalInteractiveShell.instance()
238 # needed by any code which calls __import__("__main__") after
239 # the debugger was entered. See also #9941.
240 sys.modules['__main__'] = save_main
241
242 if color_scheme is not None:
243 warnings.warn(
244 "The `color_scheme` argument is deprecated since version 5.1",
245 DeprecationWarning, stacklevel=2)
246 else:
247 color_scheme = self.shell.colors
248
249 self.aliases = {}
250
251 # Create color table: we copy the default one from the traceback
252 # module and add a few attributes needed for debugging
253 self.color_scheme_table = exception_colors()
254
255 # shorthands
256 C = coloransi.TermColors
257 cst = self.color_scheme_table
258
259 cst['NoColor'].colors.prompt = C.NoColor
260 cst['NoColor'].colors.breakpoint_enabled = C.NoColor

Callers

nothing calls this directly

Calls 4

set_colorsMethod · 0.95
get_ipythonFunction · 0.90
exception_colorsFunction · 0.90
warnMethod · 0.80

Tested by

no test coverage detected