|
12 | 12 | from ipython_genutils.py3compat import safe_unicode |
13 | 13 | from IPython.utils.tokenutil import token_at_cursor, line_at_cursor |
14 | 14 | from tornado import gen |
15 | | -from traitlets import Instance, Type, Any, List, Bool |
| 15 | +from traitlets import Instance, Type, Any, List, Bool, observe, observe_compat |
16 | 16 |
|
17 | 17 | from .comm import CommManager |
18 | 18 | from .kernelbase import Kernel as KernelBase |
@@ -43,14 +43,18 @@ class IPythonKernel(KernelBase): |
43 | 43 | ).tag(config=True) |
44 | 44 |
|
45 | 45 | user_module = Any() |
46 | | - def _user_module_changed(self, name, old, new): |
| 46 | + @observe('user_module') |
| 47 | + @observe_compat |
| 48 | + def _user_module_changed(self, change): |
47 | 49 | if self.shell is not None: |
48 | | - self.shell.user_module = new |
| 50 | + self.shell.user_module = change['new'] |
49 | 51 |
|
50 | 52 | user_ns = Instance(dict, args=None, allow_none=True) |
51 | | - def _user_ns_changed(self, name, old, new): |
| 53 | + @observe('user_ns') |
| 54 | + @observe_compat |
| 55 | + def _user_ns_changed(self, change): |
52 | 56 | if self.shell is not None: |
53 | | - self.shell.user_ns = new |
| 57 | + self.shell.user_ns = change['new'] |
54 | 58 | self.shell.init_user_ns() |
55 | 59 |
|
56 | 60 | # A reference to the Python builtin 'raw_input' function. |
|
0 commit comments