##// END OF EJS Templates
Aggregate notifications / Use delattr in rollbacks due to bulk rejection
Sylvain Corlay -
Show More
@@ -25,7 +25,7 b' from IPython.core import release, crashhandler'
25 from IPython.core.profiledir import ProfileDir, ProfileDirError
25 from IPython.core.profiledir import ProfileDir, ProfileDirError
26 from IPython.utils.path import get_ipython_dir, get_ipython_package_dir, ensure_dir_exists
26 from IPython.utils.path import get_ipython_dir, get_ipython_package_dir, ensure_dir_exists
27 from IPython.utils import py3compat
27 from IPython.utils import py3compat
28 from IPython.utils.traitlets import List, Unicode, Type, Bool, Dict, Set, Instance
28 from IPython.utils.traitlets import List, Unicode, Type, Bool, Dict, Set, Instance, Undefined
29
29
30 if os.name == 'nt':
30 if os.name == 'nt':
31 programdata = os.environ.get('PROGRAMDATA', None)
31 programdata = os.environ.get('PROGRAMDATA', None)
@@ -215,7 +215,7 b' class BaseIPythonApplication(Application):'
215 return crashhandler.crash_handler_lite(etype, evalue, tb)
215 return crashhandler.crash_handler_lite(etype, evalue, tb)
216
216
217 def _ipython_dir_changed(self, name, old, new):
217 def _ipython_dir_changed(self, name, old, new):
218 if old is not None:
218 if old is not None and old is not Undefined:
219 str_old = py3compat.cast_bytes_py2(os.path.abspath(old),
219 str_old = py3compat.cast_bytes_py2(os.path.abspath(old),
220 sys.getfilesystemencoding()
220 sys.getfilesystemencoding()
221 )
221 )
@@ -622,6 +622,8 b' class HasTraits(py3compat.with_metaclass(MetaHasTraits, object)):'
622 for name in cache:
622 for name in cache:
623 if cache[name][1] is not Undefined:
623 if cache[name][1] is not Undefined:
624 setattr(self, name, cache[name][1])
624 setattr(self, name, cache[name][1])
625 else:
626 delattr(self, name)
625 notifications = {}
627 notifications = {}
626 raise e
628 raise e
627 finally:
629 finally:
@@ -633,10 +635,9 b' class HasTraits(py3compat.with_metaclass(MetaHasTraits, object)):'
633 # remove the redundant value from __dict__
635 # remove the redundant value from __dict__
634 # (only used to preserve pickleability on Python < 3.4)
636 # (only used to preserve pickleability on Python < 3.4)
635 self.__dict__.pop('_notify_trait', None)
637 self.__dict__.pop('_notify_trait', None)
636
637 # trigger delayed notifications
638 # trigger delayed notifications
638 for name in notifications:
639 for v in dict(cache, **notifications).values():
639 self._notify_trait(*(notifications[name]))
640 self._notify_trait(*v)
640
641
641 def _notify_trait(self, name, old_value, new_value):
642 def _notify_trait(self, name, old_value, new_value):
642
643
General Comments 0
You need to be logged in to leave comments. Login now