##// END OF EJS Templates
Cleanup and add more deprecation warnings.
Matthias Bussonnier -
Show More
@@ -474,28 +474,16 b' class InteractiveShell(SingletonConfigurable):'
474 self.init_hooks()
474 self.init_hooks()
475 self.init_events()
475 self.init_events()
476 self.init_pushd_popd_magic()
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 self.init_user_ns()
477 self.init_user_ns()
480 self.init_logger()
478 self.init_logger()
481 self.init_builtins()
479 self.init_builtins()
482
480
483 # The following was in post_config_initialization
481 # The following was in post_config_initialization
484 self.init_inspector()
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 if py3compat.PY3:
483 if py3compat.PY3:
492 self.raw_input_original = input
484 self.raw_input_original = input
493 else:
485 else:
494 self.raw_input_original = raw_input
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 self.init_completer()
487 self.init_completer()
500 # TODO: init_io() needs to happen before init_traceback handlers
488 # TODO: init_io() needs to happen before init_traceback handlers
501 # because the traceback handlers hardcode the stdout/stderr streams.
489 # because the traceback handlers hardcode the stdout/stderr streams.
@@ -1,5 +1,7 b''
1 # coding: utf-8
1 # coding: utf-8
2 """
2 """
3 Deprecated since IPython 5.0
4
3 Inputhook management for GUI event loop integration.
5 Inputhook management for GUI event loop integration.
4 """
6 """
5
7
@@ -98,7 +100,9 b' else:'
98
100
99
101
100 class InputHookManager(object):
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 This class installs various hooks under ``PyOSInputHook`` to handle
107 This class installs various hooks under ``PyOSInputHook`` to handle
104 GUI event loop integration.
108 GUI event loop integration.
@@ -121,15 +125,25 b' class InputHookManager(object):'
121 self._current_gui = None
125 self._current_gui = None
122
126
123 def get_pyos_inputhook(self):
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 return ctypes.c_void_p.in_dll(ctypes.pythonapi,"PyOS_InputHook")
133 return ctypes.c_void_p.in_dll(ctypes.pythonapi,"PyOS_InputHook")
126
134
127 def get_pyos_inputhook_as_func(self):
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 return self.PYFUNC.in_dll(ctypes.pythonapi,"PyOS_InputHook")
141 return self.PYFUNC.in_dll(ctypes.pythonapi,"PyOS_InputHook")
130
142
131 def set_inputhook(self, callback):
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 # On platforms with 'readline' support, it's all too likely to
147 # On platforms with 'readline' support, it's all too likely to
134 # have a KeyboardInterrupt signal delivered *even before* an
148 # have a KeyboardInterrupt signal delivered *even before* an
135 # initial ``try:`` clause in the callback can be executed, so
149 # initial ``try:`` clause in the callback can be executed, so
@@ -145,7 +159,9 b' class InputHookManager(object):'
145 return original
159 return original
146
160
147 def clear_inputhook(self, app=None):
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 Parameters
166 Parameters
151 ----------
167 ----------
@@ -155,6 +171,8 b' class InputHookManager(object):'
155 the actual value of the parameter is ignored. This uniform interface
171 the actual value of the parameter is ignored. This uniform interface
156 makes it easier to have user-level entry points in the main IPython
172 makes it easier to have user-level entry points in the main IPython
157 app like :meth:`enable_gui`."""
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 pyos_inputhook_ptr = self.get_pyos_inputhook()
176 pyos_inputhook_ptr = self.get_pyos_inputhook()
159 original = self.get_pyos_inputhook_as_func()
177 original = self.get_pyos_inputhook_as_func()
160 pyos_inputhook_ptr.value = ctypes.c_void_p(None).value
178 pyos_inputhook_ptr.value = ctypes.c_void_p(None).value
@@ -163,7 +181,9 b' class InputHookManager(object):'
163 return original
181 return original
164
182
165 def clear_app_refs(self, gui=None):
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 Whenever we create an app for a user on qt4 or wx, we hold a
188 Whenever we create an app for a user on qt4 or wx, we hold a
169 reference to the app. This is needed because in some cases bad things
189 reference to the app. This is needed because in some cases bad things
@@ -177,13 +197,17 b' class InputHookManager(object):'
177 the app for that toolkit. References are not held for gtk or tk
197 the app for that toolkit. References are not held for gtk or tk
178 as those toolkits don't have the notion of an app.
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 if gui is None:
202 if gui is None:
181 self.apps = {}
203 self.apps = {}
182 elif gui in self.apps:
204 elif gui in self.apps:
183 del self.apps[gui]
205 del self.apps[gui]
184
206
185 def register(self, toolkitname, *aliases):
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 This is intended to be used as a class decorator. It should be passed
212 This is intended to be used as a class decorator. It should be passed
189 the names with which to register this GUI integration. The classes
213 the names with which to register this GUI integration. The classes
@@ -196,6 +220,8 b' class InputHookManager(object):'
196 def enable(self, app=None):
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 def decorator(cls):
225 def decorator(cls):
200 if ctypes is not None:
226 if ctypes is not None:
201 inst = cls(self)
227 inst = cls(self)
@@ -206,11 +232,17 b' class InputHookManager(object):'
206 return decorator
232 return decorator
207
233
208 def current_gui(self):
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 return self._current_gui
240 return self._current_gui
211
241
212 def enable_gui(self, gui=None, app=None):
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 This is a higher level method than :meth:`set_inputhook` - it uses the
247 This is a higher level method than :meth:`set_inputhook` - it uses the
216 GUI name to look up a registered object which enables the input hook
248 GUI name to look up a registered object which enables the input hook
@@ -234,6 +266,8 b' class InputHookManager(object):'
234 PyOS_InputHook wrapper object or the GUI toolkit app created, if there was
266 PyOS_InputHook wrapper object or the GUI toolkit app created, if there was
235 one.
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 if gui in (None, GUI_NONE):
271 if gui in (None, GUI_NONE):
238 return self.disable_gui()
272 return self.disable_gui()
239
273
@@ -254,18 +288,24 b' class InputHookManager(object):'
254 return app
288 return app
255
289
256 def disable_gui(self):
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 If an application was registered, this sets its ``_in_event_loop``
295 If an application was registered, this sets its ``_in_event_loop``
260 attribute to False. It then calls :meth:`clear_inputhook`.
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 gui = self._current_gui
300 gui = self._current_gui
263 if gui in self.apps:
301 if gui in self.apps:
264 self.apps[gui]._in_event_loop = False
302 self.apps[gui]._in_event_loop = False
265 return self.clear_inputhook()
303 return self.clear_inputhook()
266
304
267 class InputHookBase(object):
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 Subclasses should define an :meth:`enable` method with one argument, ``app``,
310 Subclasses should define an :meth:`enable` method with one argument, ``app``,
271 which will either be an instance of the toolkit's application class, or None.
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 @inputhook_manager.register('osx')
322 @inputhook_manager.register('osx')
283 class NullInputHook(InputHookBase):
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 def enable(self, app=None):
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 @inputhook_manager.register('wx')
331 @inputhook_manager.register('wx')
289 class WxInputHook(InputHookBase):
332 class WxInputHook(InputHookBase):
290 def enable(self, app=None):
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 Parameters
338 Parameters
294 ----------
339 ----------
@@ -309,6 +354,8 b' class WxInputHook(InputHookBase):'
309 import wx
354 import wx
310 app = wx.App(redirect=False, clearSigInt=False)
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 import wx
359 import wx
313
360
314 wx_version = V(wx.__version__).version
361 wx_version = V(wx.__version__).version
@@ -331,10 +378,14 b' class WxInputHook(InputHookBase):'
331 return app
378 return app
332
379
333 def disable(self):
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 This restores appnapp on OS X
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 if _use_appnope():
389 if _use_appnope():
339 from appnope import nap
390 from appnope import nap
340 nap()
391 nap()
@@ -342,7 +393,9 b' class WxInputHook(InputHookBase):'
342 @inputhook_manager.register('qt', 'qt4')
393 @inputhook_manager.register('qt', 'qt4')
343 class Qt4InputHook(InputHookBase):
394 class Qt4InputHook(InputHookBase):
344 def enable(self, app=None):
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 Parameters
400 Parameters
348 ----------
401 ----------
@@ -363,6 +416,8 b' class Qt4InputHook(InputHookBase):'
363 from PyQt4 import QtCore
416 from PyQt4 import QtCore
364 app = QtGui.QApplication(sys.argv)
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 from IPython.lib.inputhookqt4 import create_inputhook_qt4
421 from IPython.lib.inputhookqt4 import create_inputhook_qt4
367 app, inputhook_qt4 = create_inputhook_qt4(self.manager, app)
422 app, inputhook_qt4 = create_inputhook_qt4(self.manager, app)
368 self.manager.set_inputhook(inputhook_qt4)
423 self.manager.set_inputhook(inputhook_qt4)
@@ -373,10 +428,14 b' class Qt4InputHook(InputHookBase):'
373 return app
428 return app
374
429
375 def disable_qt4(self):
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 This restores appnapp on OS X
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 if _use_appnope():
439 if _use_appnope():
381 from appnope import nap
440 from appnope import nap
382 nap()
441 nap()
@@ -385,6 +444,8 b' class Qt4InputHook(InputHookBase):'
385 @inputhook_manager.register('qt5')
444 @inputhook_manager.register('qt5')
386 class Qt5InputHook(Qt4InputHook):
445 class Qt5InputHook(Qt4InputHook):
387 def enable(self, app=None):
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 os.environ['QT_API'] = 'pyqt5'
449 os.environ['QT_API'] = 'pyqt5'
389 return Qt4InputHook.enable(self, app)
450 return Qt4InputHook.enable(self, app)
390
451
@@ -392,7 +453,9 b' class Qt5InputHook(Qt4InputHook):'
392 @inputhook_manager.register('gtk')
453 @inputhook_manager.register('gtk')
393 class GtkInputHook(InputHookBase):
454 class GtkInputHook(InputHookBase):
394 def enable(self, app=None):
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 Parameters
460 Parameters
398 ----------
461 ----------
@@ -407,6 +470,8 b' class GtkInputHook(InputHookBase):'
407 the PyGTK to integrate with terminal based applications like
470 the PyGTK to integrate with terminal based applications like
408 IPython.
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 import gtk
475 import gtk
411 try:
476 try:
412 gtk.set_interactive(True)
477 gtk.set_interactive(True)
@@ -419,7 +484,9 b' class GtkInputHook(InputHookBase):'
419 @inputhook_manager.register('tk')
484 @inputhook_manager.register('tk')
420 class TkInputHook(InputHookBase):
485 class TkInputHook(InputHookBase):
421 def enable(self, app=None):
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 Parameters
491 Parameters
425 ----------
492 ----------
@@ -434,6 +501,8 b' class TkInputHook(InputHookBase):'
434 :class:`InputHookManager`, since creating that object automatically
501 :class:`InputHookManager`, since creating that object automatically
435 sets ``PyOS_InputHook``.
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 if app is None:
506 if app is None:
438 try:
507 try:
439 from tkinter import Tk # Py 3
508 from tkinter import Tk # Py 3
@@ -448,7 +517,9 b' class TkInputHook(InputHookBase):'
448 @inputhook_manager.register('glut')
517 @inputhook_manager.register('glut')
449 class GlutInputHook(InputHookBase):
518 class GlutInputHook(InputHookBase):
450 def enable(self, app=None):
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 Parameters
524 Parameters
454 ----------
525 ----------
@@ -471,6 +542,8 b' class GlutInputHook(InputHookBase):'
471 The default screen mode is set to:
542 The default screen mode is set to:
472 glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH
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 import OpenGL.GLUT as glut
548 import OpenGL.GLUT as glut
476 from IPython.lib.inputhookglut import glut_display_mode, \
549 from IPython.lib.inputhookglut import glut_display_mode, \
@@ -498,12 +571,16 b' class GlutInputHook(InputHookBase):'
498
571
499
572
500 def disable(self):
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 This sets PyOS_InputHook to NULL and set the display function to a
578 This sets PyOS_InputHook to NULL and set the display function to a
504 dummy one and set the timer to a dummy timer that will be triggered
579 dummy one and set the timer to a dummy timer that will be triggered
505 very far in the future.
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 import OpenGL.GLUT as glut
584 import OpenGL.GLUT as glut
508 from glut_support import glutMainLoopEvent
585 from glut_support import glutMainLoopEvent
509
586
@@ -514,7 +591,9 b' class GlutInputHook(InputHookBase):'
514 @inputhook_manager.register('pyglet')
591 @inputhook_manager.register('pyglet')
515 class PygletInputHook(InputHookBase):
592 class PygletInputHook(InputHookBase):
516 def enable(self, app=None):
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 Parameters
598 Parameters
520 ----------
599 ----------
@@ -530,6 +609,8 b' class PygletInputHook(InputHookBase):'
530 IPython.
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 from IPython.lib.inputhookpyglet import inputhook_pyglet
614 from IPython.lib.inputhookpyglet import inputhook_pyglet
534 self.manager.set_inputhook(inputhook_pyglet)
615 self.manager.set_inputhook(inputhook_pyglet)
535 return app
616 return app
@@ -538,7 +619,9 b' class PygletInputHook(InputHookBase):'
538 @inputhook_manager.register('gtk3')
619 @inputhook_manager.register('gtk3')
539 class Gtk3InputHook(InputHookBase):
620 class Gtk3InputHook(InputHookBase):
540 def enable(self, app=None):
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 Parameters
626 Parameters
544 ----------
627 ----------
@@ -553,6 +636,8 b' class Gtk3InputHook(InputHookBase):'
553 the Gtk3 to integrate with terminal based applications like
636 the Gtk3 to integrate with terminal based applications like
554 IPython.
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 from IPython.lib.inputhookgtk3 import inputhook_gtk3
641 from IPython.lib.inputhookgtk3 import inputhook_gtk3
557 self.manager.set_inputhook(inputhook_gtk3)
642 self.manager.set_inputhook(inputhook_gtk3)
558
643
@@ -568,7 +653,7 b' guis = inputhook_manager.guihooks'
568
653
569
654
570 def _deprecated_disable():
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 inputhook_manager.disable_gui()
657 inputhook_manager.disable_gui()
573 disable_wx = disable_qt4 = disable_gtk = disable_gtk3 = disable_glut = \
658 disable_wx = disable_qt4 = disable_gtk = disable_gtk3 = disable_glut = \
574 disable_pyglet = disable_osx = _deprecated_disable
659 disable_pyglet = disable_osx = _deprecated_disable
General Comments 0
You need to be logged in to leave comments. Login now