##// END OF EJS Templates
Cleanup and add more deprecation warnings.
Matthias Bussonnier -
Show More
@@ -474,28 +474,16 b' class InteractiveShell(SingletonConfigurable):'
474 474 self.init_hooks()
475 475 self.init_events()
476 476 self.init_pushd_popd_magic()
477 # self.init_traceback_handlers use to be here, but we moved it below
478 # because it and init_io have to come after init_readline.
479 477 self.init_user_ns()
480 478 self.init_logger()
481 479 self.init_builtins()
482 480
483 481 # The following was in post_config_initialization
484 482 self.init_inspector()
485 # init_readline() must come before init_io(), because init_io uses
486 # readline related things.
487 self.init_readline()
488 # We save this here in case user code replaces raw_input, but it needs
489 # to be after init_readline(), because PyPy's readline works by replacing
490 # raw_input.
491 483 if py3compat.PY3:
492 484 self.raw_input_original = input
493 485 else:
494 486 self.raw_input_original = raw_input
495 # init_completer must come after init_readline, because it needs to
496 # know whether readline is present or not system-wide to configure the
497 # completers, since the completion machinery can now operate
498 # independently of readline (e.g. over the network)
499 487 self.init_completer()
500 488 # TODO: init_io() needs to happen before init_traceback handlers
501 489 # because the traceback handlers hardcode the stdout/stderr streams.
@@ -1,5 +1,7 b''
1 1 # coding: utf-8
2 2 """
3 Deprecated since IPython 5.0
4
3 5 Inputhook management for GUI event loop integration.
4 6 """
5 7
@@ -98,7 +100,9 b' else:'
98 100
99 101
100 102 class InputHookManager(object):
101 """Manage PyOS_InputHook for different GUI toolkits.
103 """DEPRECATED since IPython 5.0
104
105 Manage PyOS_InputHook for different GUI toolkits.
102 106
103 107 This class installs various hooks under ``PyOSInputHook`` to handle
104 108 GUI event loop integration.
@@ -121,15 +125,25 b' class InputHookManager(object):'
121 125 self._current_gui = None
122 126
123 127 def get_pyos_inputhook(self):
124 """Return the current PyOS_InputHook as a ctypes.c_void_p."""
128 """DEPRECATED since IPython 5.0
129
130 Return the current PyOS_InputHook as a ctypes.c_void_p."""
131 warn("`get_pyos_inputhook` is deprecated since IPython 5.0 and will be removed in future versions.",
132 DeprecationWarning, stacklevel=2)
125 133 return ctypes.c_void_p.in_dll(ctypes.pythonapi,"PyOS_InputHook")
126 134
127 135 def get_pyos_inputhook_as_func(self):
128 """Return the current PyOS_InputHook as a ctypes.PYFUNCYPE."""
136 """DEPRECATED since IPython 5.0
137
138 Return the current PyOS_InputHook as a ctypes.PYFUNCYPE."""
139 warn("`get_pyos_inputhook_as_func` is deprecated since IPython 5.0 and will be removed in future versions.",
140 DeprecationWarning, stacklevel=2)
129 141 return self.PYFUNC.in_dll(ctypes.pythonapi,"PyOS_InputHook")
130 142
131 143 def set_inputhook(self, callback):
132 """Set PyOS_InputHook to callback and return the previous one."""
144 """DEPRECATED since IPython 5.0
145
146 Set PyOS_InputHook to callback and return the previous one."""
133 147 # On platforms with 'readline' support, it's all too likely to
134 148 # have a KeyboardInterrupt signal delivered *even before* an
135 149 # initial ``try:`` clause in the callback can be executed, so
@@ -145,7 +159,9 b' class InputHookManager(object):'
145 159 return original
146 160
147 161 def clear_inputhook(self, app=None):
148 """Set PyOS_InputHook to NULL and return the previous one.
162 """DEPRECATED since IPython 5.0
163
164 Set PyOS_InputHook to NULL and return the previous one.
149 165
150 166 Parameters
151 167 ----------
@@ -155,6 +171,8 b' class InputHookManager(object):'
155 171 the actual value of the parameter is ignored. This uniform interface
156 172 makes it easier to have user-level entry points in the main IPython
157 173 app like :meth:`enable_gui`."""
174 warn("`clear_inputhook` is deprecated since IPython 5.0 and will be removed in future versions.",
175 DeprecationWarning, stacklevel=2)
158 176 pyos_inputhook_ptr = self.get_pyos_inputhook()
159 177 original = self.get_pyos_inputhook_as_func()
160 178 pyos_inputhook_ptr.value = ctypes.c_void_p(None).value
@@ -163,7 +181,9 b' class InputHookManager(object):'
163 181 return original
164 182
165 183 def clear_app_refs(self, gui=None):
166 """Clear IPython's internal reference to an application instance.
184 """DEPRECATED since IPython 5.0
185
186 Clear IPython's internal reference to an application instance.
167 187
168 188 Whenever we create an app for a user on qt4 or wx, we hold a
169 189 reference to the app. This is needed because in some cases bad things
@@ -177,13 +197,17 b' class InputHookManager(object):'
177 197 the app for that toolkit. References are not held for gtk or tk
178 198 as those toolkits don't have the notion of an app.
179 199 """
200 warn("`clear_app_refs` is deprecated since IPython 5.0 and will be removed in future versions.",
201 DeprecationWarning, stacklevel=2)
180 202 if gui is None:
181 203 self.apps = {}
182 204 elif gui in self.apps:
183 205 del self.apps[gui]
184 206
185 207 def register(self, toolkitname, *aliases):
186 """Register a class to provide the event loop for a given GUI.
208 """DEPRECATED since IPython 5.0
209
210 Register a class to provide the event loop for a given GUI.
187 211
188 212 This is intended to be used as a class decorator. It should be passed
189 213 the names with which to register this GUI integration. The classes
@@ -196,6 +220,8 b' class InputHookManager(object):'
196 220 def enable(self, app=None):
197 221 ...
198 222 """
223 warn("`register` is deprecated since IPython 5.0 and will be removed in future versions.",
224 DeprecationWarning, stacklevel=2)
199 225 def decorator(cls):
200 226 if ctypes is not None:
201 227 inst = cls(self)
@@ -206,11 +232,17 b' class InputHookManager(object):'
206 232 return decorator
207 233
208 234 def current_gui(self):
209 """Return a string indicating the currently active GUI or None."""
235 """DEPRECATED since IPython 5.0
236
237 Return a string indicating the currently active GUI or None."""
238 warn("`current_gui` is deprecated since IPython 5.0 and will be removed in future versions.",
239 DeprecationWarning, stacklevel=2)
210 240 return self._current_gui
211 241
212 242 def enable_gui(self, gui=None, app=None):
213 """Switch amongst GUI input hooks by name.
243 """DEPRECATED since IPython 5.0
244
245 Switch amongst GUI input hooks by name.
214 246
215 247 This is a higher level method than :meth:`set_inputhook` - it uses the
216 248 GUI name to look up a registered object which enables the input hook
@@ -234,6 +266,8 b' class InputHookManager(object):'
234 266 PyOS_InputHook wrapper object or the GUI toolkit app created, if there was
235 267 one.
236 268 """
269 warn("`enable_gui` is deprecated since IPython 5.0 and will be removed in future versions.",
270 DeprecationWarning, stacklevel=2)
237 271 if gui in (None, GUI_NONE):
238 272 return self.disable_gui()
239 273
@@ -250,22 +284,28 b' class InputHookManager(object):'
250 284 app = gui_hook.enable(app)
251 285 if app is not None:
252 286 app._in_event_loop = True
253 self.apps[gui] = app
287 self.apps[gui] = app
254 288 return app
255 289
256 290 def disable_gui(self):
257 """Disable GUI event loop integration.
291 """DEPRECATED since IPython 5.0
292
293 Disable GUI event loop integration.
258 294
259 295 If an application was registered, this sets its ``_in_event_loop``
260 296 attribute to False. It then calls :meth:`clear_inputhook`.
261 297 """
298 warn("`disable_gui` is deprecated since IPython 5.0 and will be removed in future versions.",
299 DeprecationWarning, stacklevel=2)
262 300 gui = self._current_gui
263 301 if gui in self.apps:
264 302 self.apps[gui]._in_event_loop = False
265 303 return self.clear_inputhook()
266 304
267 305 class InputHookBase(object):
268 """Base class for input hooks for specific toolkits.
306 """DEPRECATED since IPython 5.0
307
308 Base class for input hooks for specific toolkits.
269 309
270 310 Subclasses should define an :meth:`enable` method with one argument, ``app``,
271 311 which will either be an instance of the toolkit's application class, or None.
@@ -281,14 +321,19 b' inputhook_manager = InputHookManager()'
281 321
282 322 @inputhook_manager.register('osx')
283 323 class NullInputHook(InputHookBase):
284 """A null inputhook that doesn't need to do anything"""
324 """DEPRECATED since IPython 5.0
325
326 A null inputhook that doesn't need to do anything"""
285 327 def enable(self, app=None):
286 pass
328 warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
329 DeprecationWarning, stacklevel=2)
287 330
288 331 @inputhook_manager.register('wx')
289 332 class WxInputHook(InputHookBase):
290 333 def enable(self, app=None):
291 """Enable event loop integration with wxPython.
334 """DEPRECATED since IPython 5.0
335
336 Enable event loop integration with wxPython.
292 337
293 338 Parameters
294 339 ----------
@@ -309,6 +354,8 b' class WxInputHook(InputHookBase):'
309 354 import wx
310 355 app = wx.App(redirect=False, clearSigInt=False)
311 356 """
357 warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
358 DeprecationWarning, stacklevel=2)
312 359 import wx
313 360
314 361 wx_version = V(wx.__version__).version
@@ -331,10 +378,14 b' class WxInputHook(InputHookBase):'
331 378 return app
332 379
333 380 def disable(self):
334 """Disable event loop integration with wxPython.
381 """DEPRECATED since IPython 5.0
382
383 Disable event loop integration with wxPython.
335 384
336 385 This restores appnapp on OS X
337 386 """
387 warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
388 DeprecationWarning, stacklevel=2)
338 389 if _use_appnope():
339 390 from appnope import nap
340 391 nap()
@@ -342,7 +393,9 b' class WxInputHook(InputHookBase):'
342 393 @inputhook_manager.register('qt', 'qt4')
343 394 class Qt4InputHook(InputHookBase):
344 395 def enable(self, app=None):
345 """Enable event loop integration with PyQt4.
396 """DEPRECATED since IPython 5.0
397
398 Enable event loop integration with PyQt4.
346 399
347 400 Parameters
348 401 ----------
@@ -363,6 +416,8 b' class Qt4InputHook(InputHookBase):'
363 416 from PyQt4 import QtCore
364 417 app = QtGui.QApplication(sys.argv)
365 418 """
419 warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
420 DeprecationWarning, stacklevel=2)
366 421 from IPython.lib.inputhookqt4 import create_inputhook_qt4
367 422 app, inputhook_qt4 = create_inputhook_qt4(self.manager, app)
368 423 self.manager.set_inputhook(inputhook_qt4)
@@ -373,10 +428,14 b' class Qt4InputHook(InputHookBase):'
373 428 return app
374 429
375 430 def disable_qt4(self):
376 """Disable event loop integration with PyQt4.
431 """DEPRECATED since IPython 5.0
432
433 Disable event loop integration with PyQt4.
377 434
378 435 This restores appnapp on OS X
379 436 """
437 warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
438 DeprecationWarning, stacklevel=2)
380 439 if _use_appnope():
381 440 from appnope import nap
382 441 nap()
@@ -385,6 +444,8 b' class Qt4InputHook(InputHookBase):'
385 444 @inputhook_manager.register('qt5')
386 445 class Qt5InputHook(Qt4InputHook):
387 446 def enable(self, app=None):
447 warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
448 DeprecationWarning, stacklevel=2)
388 449 os.environ['QT_API'] = 'pyqt5'
389 450 return Qt4InputHook.enable(self, app)
390 451
@@ -392,7 +453,9 b' class Qt5InputHook(Qt4InputHook):'
392 453 @inputhook_manager.register('gtk')
393 454 class GtkInputHook(InputHookBase):
394 455 def enable(self, app=None):
395 """Enable event loop integration with PyGTK.
456 """DEPRECATED since IPython 5.0
457
458 Enable event loop integration with PyGTK.
396 459
397 460 Parameters
398 461 ----------
@@ -407,6 +470,8 b' class GtkInputHook(InputHookBase):'
407 470 the PyGTK to integrate with terminal based applications like
408 471 IPython.
409 472 """
473 warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
474 DeprecationWarning, stacklevel=2)
410 475 import gtk
411 476 try:
412 477 gtk.set_interactive(True)
@@ -419,7 +484,9 b' class GtkInputHook(InputHookBase):'
419 484 @inputhook_manager.register('tk')
420 485 class TkInputHook(InputHookBase):
421 486 def enable(self, app=None):
422 """Enable event loop integration with Tk.
487 """DEPRECATED since IPython 5.0
488
489 Enable event loop integration with Tk.
423 490
424 491 Parameters
425 492 ----------
@@ -434,6 +501,8 b' class TkInputHook(InputHookBase):'
434 501 :class:`InputHookManager`, since creating that object automatically
435 502 sets ``PyOS_InputHook``.
436 503 """
504 warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
505 DeprecationWarning, stacklevel=2)
437 506 if app is None:
438 507 try:
439 508 from tkinter import Tk # Py 3
@@ -448,7 +517,9 b' class TkInputHook(InputHookBase):'
448 517 @inputhook_manager.register('glut')
449 518 class GlutInputHook(InputHookBase):
450 519 def enable(self, app=None):
451 """Enable event loop integration with GLUT.
520 """DEPRECATED since IPython 5.0
521
522 Enable event loop integration with GLUT.
452 523
453 524 Parameters
454 525 ----------
@@ -471,6 +542,8 b' class GlutInputHook(InputHookBase):'
471 542 The default screen mode is set to:
472 543 glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH
473 544 """
545 warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
546 DeprecationWarning, stacklevel=2)
474 547
475 548 import OpenGL.GLUT as glut
476 549 from IPython.lib.inputhookglut import glut_display_mode, \
@@ -498,12 +571,16 b' class GlutInputHook(InputHookBase):'
498 571
499 572
500 573 def disable(self):
501 """Disable event loop integration with glut.
574 """DEPRECATED since IPython 5.0
575
576 Disable event loop integration with glut.
502 577
503 578 This sets PyOS_InputHook to NULL and set the display function to a
504 579 dummy one and set the timer to a dummy timer that will be triggered
505 580 very far in the future.
506 581 """
582 warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
583 DeprecationWarning, stacklevel=2)
507 584 import OpenGL.GLUT as glut
508 585 from glut_support import glutMainLoopEvent
509 586
@@ -514,7 +591,9 b' class GlutInputHook(InputHookBase):'
514 591 @inputhook_manager.register('pyglet')
515 592 class PygletInputHook(InputHookBase):
516 593 def enable(self, app=None):
517 """Enable event loop integration with pyglet.
594 """DEPRECATED since IPython 5.0
595
596 Enable event loop integration with pyglet.
518 597
519 598 Parameters
520 599 ----------
@@ -530,6 +609,8 b' class PygletInputHook(InputHookBase):'
530 609 IPython.
531 610
532 611 """
612 warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
613 DeprecationWarning, stacklevel=2)
533 614 from IPython.lib.inputhookpyglet import inputhook_pyglet
534 615 self.manager.set_inputhook(inputhook_pyglet)
535 616 return app
@@ -538,7 +619,9 b' class PygletInputHook(InputHookBase):'
538 619 @inputhook_manager.register('gtk3')
539 620 class Gtk3InputHook(InputHookBase):
540 621 def enable(self, app=None):
541 """Enable event loop integration with Gtk3 (gir bindings).
622 """DEPRECATED since IPython 5.0
623
624 Enable event loop integration with Gtk3 (gir bindings).
542 625
543 626 Parameters
544 627 ----------
@@ -553,6 +636,8 b' class Gtk3InputHook(InputHookBase):'
553 636 the Gtk3 to integrate with terminal based applications like
554 637 IPython.
555 638 """
639 warn("This function is deprecated since IPython 5.0 and will be removed in future versions.",
640 DeprecationWarning, stacklevel=2)
556 641 from IPython.lib.inputhookgtk3 import inputhook_gtk3
557 642 self.manager.set_inputhook(inputhook_gtk3)
558 643
@@ -568,7 +653,7 b' guis = inputhook_manager.guihooks'
568 653
569 654
570 655 def _deprecated_disable():
571 warn("This function is deprecated: use disable_gui() instead")
656 warn("This function is deprecated since IPython 4.0 use disable_gui() instead", DeprecationWarning)
572 657 inputhook_manager.disable_gui()
573 658 disable_wx = disable_qt4 = disable_gtk = disable_gtk3 = disable_glut = \
574 659 disable_pyglet = disable_osx = _deprecated_disable
General Comments 0
You need to be logged in to leave comments. Login now