Show More
@@ -1,80 +1,80 b'' | |||||
1 | # encoding: utf-8 |
|
1 | # encoding: utf-8 | |
2 | """ |
|
2 | """ | |
3 | A utility for handling the reloading of doctest. |
|
3 | A utility for handling the reloading of doctest. | |
4 | """ |
|
4 | """ | |
5 |
|
5 | |||
6 | #----------------------------------------------------------------------------- |
|
6 | #----------------------------------------------------------------------------- | |
7 | # Copyright (C) 2008-2011 The IPython Development Team |
|
7 | # Copyright (C) 2008-2011 The IPython Development Team | |
8 | # |
|
8 | # | |
9 | # Distributed under the terms of the BSD License. The full license is in |
|
9 | # Distributed under the terms of the BSD License. The full license is in | |
10 | # the file COPYING, distributed as part of this software. |
|
10 | # the file COPYING, distributed as part of this software. | |
11 | #----------------------------------------------------------------------------- |
|
11 | #----------------------------------------------------------------------------- | |
12 |
|
12 | |||
13 | #----------------------------------------------------------------------------- |
|
13 | #----------------------------------------------------------------------------- | |
14 | # Imports |
|
14 | # Imports | |
15 | #----------------------------------------------------------------------------- |
|
15 | #----------------------------------------------------------------------------- | |
16 |
|
16 | |||
17 | import sys |
|
17 | import sys | |
18 |
|
18 | |||
19 | #----------------------------------------------------------------------------- |
|
19 | #----------------------------------------------------------------------------- | |
20 | # Code |
|
20 | # Code | |
21 | #----------------------------------------------------------------------------- |
|
21 | #----------------------------------------------------------------------------- | |
22 |
|
22 | |||
23 | def dhook_wrap(func,*a,**k): |
|
23 | def dhook_wrap(func,*a,**k): | |
24 | """Wrap a function call in a sys.displayhook controller. |
|
24 | """Wrap a function call in a sys.displayhook controller. | |
25 |
|
25 | |||
26 | Returns a wrapper around func which calls func, with all its arguments and |
|
26 | Returns a wrapper around func which calls func, with all its arguments and | |
27 | keywords unmodified, using the default sys.displayhook. Since IPython |
|
27 | keywords unmodified, using the default sys.displayhook. Since IPython | |
28 | modifies sys.displayhook, it breaks the behavior of certain systems that |
|
28 | modifies sys.displayhook, it breaks the behavior of certain systems that | |
29 | rely on the default behavior, notably doctest. |
|
29 | rely on the default behavior, notably doctest. | |
30 | """ |
|
30 | """ | |
31 |
|
31 | |||
32 | def f(*a,**k): |
|
32 | def f(*a,**k): | |
33 |
|
33 | |||
34 | dhook_s = sys.displayhook |
|
34 | dhook_s = sys.displayhook | |
35 | sys.displayhook = sys.__displayhook__ |
|
35 | sys.displayhook = sys.__displayhook__ | |
36 | try: |
|
36 | try: | |
37 | out = func(*a,**k) |
|
37 | out = func(*a,**k) | |
38 | finally: |
|
38 | finally: | |
39 | sys.displayhook = dhook_s |
|
39 | sys.displayhook = dhook_s | |
40 |
|
40 | |||
41 | return out |
|
41 | return out | |
42 |
|
42 | |||
43 | f.__doc__ = func.__doc__ |
|
43 | f.__doc__ = func.__doc__ | |
44 | return f |
|
44 | return f | |
45 |
|
45 | |||
46 |
|
46 | |||
47 | def doctest_reload(): |
|
47 | def doctest_reload(): | |
48 | """Properly reload doctest to reuse it interactively. |
|
48 | """Properly reload doctest to reuse it interactively. | |
49 |
|
49 | |||
50 | This routine: |
|
50 | This routine: | |
51 |
|
51 | |||
52 | - imports doctest but does NOT reload it (see below). |
|
52 | - imports doctest but does NOT reload it (see below). | |
53 |
|
53 | |||
54 | - resets its global 'master' attribute to None, so that multiple uses of |
|
54 | - resets its global 'master' attribute to None, so that multiple uses of | |
55 | the module interactively don't produce cumulative reports. |
|
55 | the module interactively don't produce cumulative reports. | |
56 |
|
56 | |||
57 | - Monkeypatches its core test runner method to protect it from IPython's |
|
57 | - Monkeypatches its core test runner method to protect it from IPython's | |
58 | modified displayhook. Doctest expects the default displayhook behavior |
|
58 | modified displayhook. Doctest expects the default displayhook behavior | |
59 | deep down, so our modification breaks it completely. For this reason, a |
|
59 | deep down, so our modification breaks it completely. For this reason, a | |
60 | hard monkeypatch seems like a reasonable solution rather than asking |
|
60 | hard monkeypatch seems like a reasonable solution rather than asking | |
61 | users to manually use a different doctest runner when under IPython. |
|
61 | users to manually use a different doctest runner when under IPython. | |
62 |
|
62 | |||
63 | Notes |
|
63 | Notes | |
64 | ----- |
|
64 | ----- | |
65 |
|
65 | |||
66 | As of Python 2.6.6, 2.7.1 and 3.2, this monkeypatching is no longer required. |
|
66 | As of Python 2.6.6, 2.7.1 and 3.2, this monkeypatching is no longer required. | |
67 | doctest now takes care of resetting sys.displayhook itself. This function |
|
67 | doctest now takes care of resetting sys.displayhook itself. This function | |
68 | remains for now in case anyone has to work with older versions, but it's |
|
68 | remains for now in case anyone has to work with older versions, but it's | |
69 | no longer called during IPython startup. |
|
69 | no longer called during IPython startup. | |
70 |
|
70 | |||
71 | This function *used to* reload doctest, but this has been disabled because |
|
71 | This function *used to* reload doctest, but this has been disabled because | |
72 | reloading doctest unconditionally can cause massive breakage of other |
|
72 | reloading doctest unconditionally can cause massive breakage of other | |
73 | doctest-dependent modules already in memory, such as those for IPython's |
|
73 | doctest-dependent modules already in memory, such as those for IPython's | |
74 | own testing system. The name wasn't changed to avoid breaking people's |
|
74 | own testing system. The name wasn't changed to avoid breaking people's | |
75 | code, but the reload call isn't actually made anymore.""" |
|
75 | code, but the reload call isn't actually made anymore.""" | |
76 |
|
76 | |||
77 | import doctest |
|
77 | import doctest | |
78 | doctest.master = None |
|
78 | doctest.master = None | |
79 | doctest.DocTestRunner.run = dhook_wrap(doctest.DocTestRunner.run) |
|
79 | doctest.DocTestRunner.run = dhook_wrap(doctest.DocTestRunner.run) | |
80 |
|
80 |
@@ -1,42 +1,46 b'' | |||||
1 | ===================== |
|
1 | ===================== | |
2 | Development version |
|
2 | Development version | |
3 | ===================== |
|
3 | ===================== | |
4 |
|
4 | |||
5 | This document describes in-flight development work. |
|
5 | This document describes in-flight development work. | |
6 |
|
6 | |||
7 | The CodeMirror js library has been updated fron 2.23 to 2.32 |
|
7 | The CodeMirror js library has been updated fron 2.23 to 2.32 | |
8 | this might induce a few changes in behavior of keymaps in the notebook, |
|
8 | this might induce a few changes in behavior of keymaps in the notebook, | |
9 | especially intenting/deindenting blocks that is now bound to Ctrl+] and ctr+[ |
|
9 | especially intenting/deindenting blocks that is now bound to Ctrl+] and ctr+[ | |
10 |
|
10 | |||
11 | * Exception types can now be displayed with a custom traceback, by defining a |
|
11 | * Exception types can now be displayed with a custom traceback, by defining a | |
12 | ``_render_traceback_()`` method which returns a list of strings, each |
|
12 | ``_render_traceback_()`` method which returns a list of strings, each | |
13 | containing one line of the traceback. |
|
13 | containing one line of the traceback. | |
14 | * A new command, ``ipython history trim`` can be used to delete everything but |
|
14 | * A new command, ``ipython history trim`` can be used to delete everything but | |
15 | the last 1000 entries in the history database. |
|
15 | the last 1000 entries in the history database. | |
16 |
|
16 | |||
17 | In-process kernels |
|
17 | In-process kernels | |
18 | ------------------ |
|
18 | ------------------ | |
19 |
|
19 | |||
20 | The Python-language frontends, particularly the Qt console, may now communicate |
|
20 | The Python-language frontends, particularly the Qt console, may now communicate | |
21 | with in-process kernels, in addition to the traditional out-of-process |
|
21 | with in-process kernels, in addition to the traditional out-of-process | |
22 | kernels. An in-process kernel permits direct access to the kernel namespace, |
|
22 | kernels. An in-process kernel permits direct access to the kernel namespace, | |
23 | which is necessary in some applications. It should be understood, however, that |
|
23 | which is necessary in some applications. It should be understood, however, that | |
24 | the in-process kernel is not robust to bad user input and will block the main |
|
24 | the in-process kernel is not robust to bad user input and will block the main | |
25 | (GUI) thread while executing. Developers must decide on a case-by-case basis |
|
25 | (GUI) thread while executing. Developers must decide on a case-by-case basis | |
26 | whether this tradeoff is appropriate for their application. |
|
26 | whether this tradeoff is appropriate for their application. | |
27 |
|
27 | |||
28 | Backwards incompatible changes |
|
28 | Backwards incompatible changes | |
29 | ------------------------------ |
|
29 | ------------------------------ | |
30 |
|
30 | |||
31 | * Calling :meth:`InteractiveShell.prefilter` will no longer perform static |
|
31 | * Calling :meth:`InteractiveShell.prefilter` will no longer perform static | |
32 | transformations - the processing of escaped commands such as ``%magic`` and |
|
32 | transformations - the processing of escaped commands such as ``%magic`` and | |
33 | ``!system``, and stripping input prompts from code blocks. This functionality |
|
33 | ``!system``, and stripping input prompts from code blocks. This functionality | |
34 | was duplicated in :mod:`IPython.core.inputsplitter`, and the latter version |
|
34 | was duplicated in :mod:`IPython.core.inputsplitter`, and the latter version | |
35 | was already what IPython relied on. A new API to transform input will be ready |
|
35 | was already what IPython relied on. A new API to transform input will be ready | |
36 | before release. |
|
36 | before release. | |
37 | * Functions from :mod:`IPython.lib.inputhook` to control integration with GUI |
|
37 | * Functions from :mod:`IPython.lib.inputhook` to control integration with GUI | |
38 | event loops are no longer exposed in the top level of :mod:`IPython.lib`. |
|
38 | event loops are no longer exposed in the top level of :mod:`IPython.lib`. | |
39 | Code calling these should make sure to import them from |
|
39 | Code calling these should make sure to import them from | |
40 | :mod:`IPython.lib.inputhook`. |
|
40 | :mod:`IPython.lib.inputhook`. | |
41 | * For all kernel managers, the ``sub_channel`` attribute has been renamed to |
|
41 | * For all kernel managers, the ``sub_channel`` attribute has been renamed to | |
42 | ``iopub_channel``. |
|
42 | ``iopub_channel``. | |
|
43 | * Users on Python versions before 2.6.6, 2.7.1 or 3.2 will now need to call | |||
|
44 | :func:`IPython.utils.doctestreload.doctest_reload` to make doctests run | |||
|
45 | correctly inside IPython. Python releases since those versions are unaffected. | |||
|
46 | For details, see :ghpull:`3068` and `Python issue 8048 <http://bugs.python.org/issue8048>`_. |
General Comments 0
You need to be logged in to leave comments.
Login now