Commit f0671ca
committed
BUG: fix IPython's %pylab mode detection
There is no pyplot module in the system registry, as the module is
imported as matplotlib.pyplot.
This code tries to detect when matplotlib.pyplot.show() is invoked in
a script run via the %run IPython's magic while in interactive mode as
enabled by the %pylab or %matplotlib IPyhton's magic commands. In these
modes, matplotlib.pyplot.show() should not block.
Failing do detect these modes, a simple test.py script as this
import matplotlib.pyplot as plt
plt.figure()
plt.show()
run in IPython as follows
%matplotlib
%run test.py
is not expected to block on matplotlib.pyplot.show(). Without this
patch it does. Additionally, the redraw implemented by IPython at the
end of %run caused an empty figure to be displayed when the script
terminates.
Fixing the module lookup in sys.modules fixes the issue.
Fixes: 86f26a0.
Fixes: matplotlib#25485.1 parent 78bf53c commit f0671ca
1 file changed
+4
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2930 | 2930 | | |
2931 | 2931 | | |
2932 | 2932 | | |
2933 | | - | |
2934 | | - | |
| 2933 | + | |
| 2934 | + | |
2935 | 2935 | | |
2936 | 2936 | | |
2937 | 2937 | | |
| |||
3645 | 3645 | | |
3646 | 3646 | | |
3647 | 3647 | | |
3648 | | - | |
3649 | | - | |
| 3648 | + | |
| 3649 | + | |
3650 | 3650 | | |
3651 | 3651 | | |
3652 | 3652 | | |
| |||
0 commit comments