Show More
@@ -37,6 +37,7 b' example, you could use a startup file like this::' | |||
|
37 | 37 | |
|
38 | 38 | import os |
|
39 | 39 | import subprocess |
|
40 | import warnings | |
|
40 | 41 | import sys |
|
41 | 42 | |
|
42 | 43 | from IPython.core.error import TryNext |
@@ -83,13 +84,24 b' def editor(self, filename, linenum=None, wait=True):' | |||
|
83 | 84 | |
|
84 | 85 | import tempfile |
|
85 | 86 | def fix_error_editor(self,filename,linenum,column,msg): |
|
86 | """Open the editor at the given filename, linenumber, column and | |
|
87 | """DEPRECATED | |
|
88 | ||
|
89 | Open the editor at the given filename, linenumber, column and | |
|
87 | 90 | show an error message. This is used for correcting syntax errors. |
|
88 | 91 | The current implementation only has special support for the VIM editor, |
|
89 | 92 | and falls back on the 'editor' hook if VIM is not used. |
|
90 | 93 | |
|
91 | Call ip.set_hook('fix_error_editor',youfunc) to use your own function, | |
|
94 | Call ip.set_hook('fix_error_editor',yourfunc) to use your own function, | |
|
92 | 95 | """ |
|
96 | ||
|
97 | warnings.warn(""" | |
|
98 | `fix_error_editor` is pending deprecation as of IPython 5.0 and will be removed | |
|
99 | in future versions. It appears to be used only for automatically fixing syntax | |
|
100 | error that has been broken for a few years and has thus been removed. If you | |
|
101 | happend to use this function and still need it please make your voice heard on | |
|
102 | the mailing list ipython-dev@scipy.org , or on the GitHub Issue tracker: | |
|
103 | https://github.com/ipython/ipython/issues/9649 """, UserWarning) | |
|
104 | ||
|
93 | 105 | def vim_quickfix_file(): |
|
94 | 106 | t = tempfile.NamedTemporaryFile() |
|
95 | 107 | t.write('%s:%d:%d:%s\n' % (filename,linenum,column,msg)) |
@@ -93,11 +93,6 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
93 | 93 | def debugger_cls(self): |
|
94 | 94 | return Pdb if self.simple_prompt else TerminalPdb |
|
95 | 95 | |
|
96 | autoedit_syntax = Bool(False, | |
|
97 | help="auto editing of files with syntax errors.", | |
|
98 | ).tag(config=True) | |
|
99 | ||
|
100 | ||
|
101 | 96 | confirm_exit = Bool(True, |
|
102 | 97 | help=""" |
|
103 | 98 | Set to confirm when you try to exit IPython with an EOF (Control-D |
@@ -476,8 +471,6 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
476 | 471 | else: |
|
477 | 472 | if code: |
|
478 | 473 | self.run_cell(code, store_history=True) |
|
479 | if self.autoedit_syntax and self.SyntaxTB.last_syntax_error: | |
|
480 | self.edit_syntax_error() | |
|
481 | 474 | |
|
482 | 475 | def mainloop(self, display_banner=DISPLAY_BANNER_DEPRECATED): |
|
483 | 476 | # An extra layer of protection in case someone mashing Ctrl-C breaks |
@@ -505,65 +498,6 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
505 | 498 | else: |
|
506 | 499 | self._inputhook = None |
|
507 | 500 | |
|
508 | # Methods to support auto-editing of SyntaxErrors: | |
|
509 | ||
|
510 | def edit_syntax_error(self): | |
|
511 | """The bottom half of the syntax error handler called in the main loop. | |
|
512 | ||
|
513 | Loop until syntax error is fixed or user cancels. | |
|
514 | """ | |
|
515 | ||
|
516 | while self.SyntaxTB.last_syntax_error: | |
|
517 | # copy and clear last_syntax_error | |
|
518 | err = self.SyntaxTB.clear_err_state() | |
|
519 | if not self._should_recompile(err): | |
|
520 | return | |
|
521 | try: | |
|
522 | # may set last_syntax_error again if a SyntaxError is raised | |
|
523 | self.safe_execfile(err.filename, self.user_ns) | |
|
524 | except: | |
|
525 | self.showtraceback() | |
|
526 | else: | |
|
527 | try: | |
|
528 | with open(err.filename) as f: | |
|
529 | # This should be inside a display_trap block and I | |
|
530 | # think it is. | |
|
531 | sys.displayhook(f.read()) | |
|
532 | except: | |
|
533 | self.showtraceback() | |
|
534 | ||
|
535 | def _should_recompile(self, e): | |
|
536 | """Utility routine for edit_syntax_error""" | |
|
537 | ||
|
538 | if e.filename in ('<ipython console>', '<input>', '<string>', | |
|
539 | '<console>', '<BackgroundJob compilation>', | |
|
540 | None): | |
|
541 | return False | |
|
542 | try: | |
|
543 | if (self.autoedit_syntax and | |
|
544 | not self.ask_yes_no( | |
|
545 | 'Return to editor to correct syntax error? ' | |
|
546 | '[Y/n] ', 'y')): | |
|
547 | return False | |
|
548 | except EOFError: | |
|
549 | return False | |
|
550 | ||
|
551 | def int0(x): | |
|
552 | try: | |
|
553 | return int(x) | |
|
554 | except TypeError: | |
|
555 | return 0 | |
|
556 | ||
|
557 | # always pass integer line and offset values to editor hook | |
|
558 | try: | |
|
559 | self.hooks.fix_error_editor(e.filename, | |
|
560 | int0(e.lineno), int0(e.offset), | |
|
561 | e.msg) | |
|
562 | except TryNext: | |
|
563 | warn('Could not open editor') | |
|
564 | return False | |
|
565 | return True | |
|
566 | ||
|
567 | 501 | # Run !system commands directly, not through pipes, so terminal programs |
|
568 | 502 | # work correctly. |
|
569 | 503 | system = InteractiveShell.system_raw |
@@ -64,8 +64,6 b' Most of the above remarks also affect `IPython.core.debugger.Pdb`, the `%debug`' | |||
|
64 | 64 | and `%pdb` magic which do not use readline anymore either. |
|
65 | 65 | |
|
66 | 66 | |
|
67 | ||
|
68 | ||
|
69 | 67 | Provisional Changes |
|
70 | 68 | ------------------- |
|
71 | 69 | |
@@ -109,6 +107,34 b' widgets... As stated above this is nightly experimental feature with a lot of' | |||
|
109 | 107 | it. |
|
110 | 108 | |
|
111 | 109 | |
|
110 | Removed Feature | |
|
111 | --------------- | |
|
112 | ||
|
113 | - ``TerminalInteractiveShell.autoedit_syntax`` Has been broken for many years now | |
|
114 | apparently. It has been removed. | |
|
115 | ||
|
116 | ||
|
117 | Deprecated Features | |
|
118 | ------------------- | |
|
119 | ||
|
120 | Some deprecated feature, don't forget to enable `DeprecationWarning` as error | |
|
121 | of you are using IPython in Continuous Integration setup or in your testing in general: | |
|
122 | ||
|
123 | .. code:: | |
|
124 | :python: | |
|
125 | ||
|
126 | import warnings | |
|
127 | warnings.filterwarnings('error', '.*', DeprecationWarning, module='yourmodule.*') | |
|
128 | ||
|
129 | ||
|
130 | - `hooks.fix_error_editor` seem to be unused and is pending deprecation. | |
|
131 | - `IPython/core/excolors.py:ExceptionColors` is deprecated. | |
|
132 | - `IPython.core.InteractiveShell:write()` is deprecated, use `sys.stdout` instead. | |
|
133 | - `IPython.core.InteractiveShell:write_err()` is deprecated, use `sys.stderr` instead. | |
|
134 | - The `formatter` keyword argument to `Inspector.info` in `IPython.core.oinspec` has now no effects. | |
|
135 | - The `global_ns` keyword argument of IPython Embed was deprecated, and will now have no effect. Use `module` keyword argument instead. | |
|
136 | ||
|
137 | ||
|
112 | 138 | Known Issues: |
|
113 | 139 | ------------- |
|
114 | 140 |
General Comments 0
You need to be logged in to leave comments.
Login now