Show More
@@ -20,6 +20,7 b' from __future__ import absolute_import' | |||
|
20 | 20 | import __builtin__ |
|
21 | 21 | import __future__ |
|
22 | 22 | import abc |
|
23 | import atexit | |
|
23 | 24 | import codeop |
|
24 | 25 | import exceptions |
|
25 | 26 | import new |
@@ -276,6 +277,7 b' class InteractiveShell(Configurable, Magic):' | |||
|
276 | 277 | self.init_plugin_manager() |
|
277 | 278 | self.init_payload() |
|
278 | 279 | self.hooks.late_startup_hook() |
|
280 | atexit.register(self.atexit_operations) | |
|
279 | 281 | |
|
280 | 282 | @classmethod |
|
281 | 283 | def instance(cls, *args, **kwargs): |
@@ -1605,8 +1607,6 b' class InteractiveShell(Configurable, Magic):' | |||
|
1605 | 1607 | self.has_readline = True |
|
1606 | 1608 | self.readline = readline |
|
1607 | 1609 | sys.modules['readline'] = readline |
|
1608 | import atexit | |
|
1609 | ### | |
|
1610 | 1610 | |
|
1611 | 1611 | from IPython.core.completer import IPCompleter |
|
1612 | 1612 | self.Completer = IPCompleter(self, |
@@ -1620,6 +1620,9 b' class InteractiveShell(Configurable, Magic):' | |||
|
1620 | 1620 | |
|
1621 | 1621 | # Platform-specific configuration |
|
1622 | 1622 | if os.name == 'nt': |
|
1623 | # FIXME - check with Frederick to see if we can harmonize | |
|
1624 | # naming conventions with pyreadline to avoid this | |
|
1625 | # platform-dependent check | |
|
1623 | 1626 | self.readline_startup_hook = readline.set_pre_input_hook |
|
1624 | 1627 | else: |
|
1625 | 1628 | self.readline_startup_hook = readline.set_startup_hook |
@@ -1666,8 +1669,9 b' class InteractiveShell(Configurable, Magic):' | |||
|
1666 | 1669 | except IOError: |
|
1667 | 1670 | pass # It doesn't exist yet. |
|
1668 | 1671 | |
|
1669 | atexit.register(self.atexit_operations) | |
|
1670 |
|
|
|
1672 | # If we have readline, we want our history saved upon ipython | |
|
1673 | # exiting. | |
|
1674 | atexit.register(self.savehist) | |
|
1671 | 1675 | |
|
1672 | 1676 | # Configure auto-indent for all platforms |
|
1673 | 1677 | self.set_autoindent(self.autoindent) |
@@ -2328,14 +2332,17 b' class InteractiveShell(Configurable, Magic):' | |||
|
2328 | 2332 | #------------------------------------------------------------------------- |
|
2329 | 2333 | # Things related to IPython exiting |
|
2330 | 2334 | #------------------------------------------------------------------------- |
|
2331 | ||
|
2332 | 2335 | def atexit_operations(self): |
|
2333 | 2336 | """This will be executed at the time of exit. |
|
2334 | 2337 | |
|
2335 | Saving of persistent data should be performed here. | |
|
2336 | """ | |
|
2337 | self.savehist() | |
|
2338 | Cleanup operations and saving of persistent data that is done | |
|
2339 | unconditionally by IPython should be performed here. | |
|
2338 | 2340 |
|
|
2341 | For things that may depend on startup flags or platform specifics (such | |
|
2342 | as having readline or not), register a separate atexit function in the | |
|
2343 | code that has the appropriate information, rather than trying to | |
|
2344 | clutter | |
|
2345 | """ | |
|
2339 | 2346 | # Cleanup all tempfiles left around |
|
2340 | 2347 | for tfile in self.tempfiles: |
|
2341 | 2348 | try: |
@@ -289,7 +289,7 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
289 | 289 | # We must ensure that our completer is back in place. |
|
290 | 290 | |
|
291 | 291 | if self.has_readline: |
|
292 | self.set_completer() | |
|
292 | self.set_readline_completer() | |
|
293 | 293 | |
|
294 | 294 | try: |
|
295 | 295 | line = raw_input_original(prompt).decode(self.stdin_encoding) |
General Comments 0
You need to be logged in to leave comments.
Login now