Restore the state of the sys module.
(self)
| 961 | self._orig_sys_modules_main_mod = sys.modules.get(self.user_module.__name__) |
| 962 | |
| 963 | def restore_sys_module_state(self): |
| 964 | """Restore the state of the sys module.""" |
| 965 | try: |
| 966 | for k, v in self._orig_sys_module_state.items(): |
| 967 | setattr(sys, k, v) |
| 968 | except AttributeError: |
| 969 | pass |
| 970 | # Reset what what done in self.init_sys_modules |
| 971 | if self._orig_sys_modules_main_mod is not None: |
| 972 | sys.modules[self._orig_sys_modules_main_name] = self._orig_sys_modules_main_mod |
| 973 | |
| 974 | #------------------------------------------------------------------------- |
| 975 | # Things related to the banner |