FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Raise ImportError on failure to import backends. by anntzer · Pull Request #11519 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .m  (1) .py  (1) .rst  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
6 changes: 6 additions & 0 deletions doc/api/next_api_changes/2018-06-27-AL.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Changes to backend loading
``````````````````````````

Failure to load backend modules (``macosx`` on non-framework builds and
``gtk3`` when running headless) now raises `ImportError` (instead of
`RuntimeError` and `TypeError`, respectively.
17 changes: 11 additions & 6 deletions lib/matplotlib/backends/backend_gtk3.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@
# see http://groups.google.com/groups?q=screen+dpi+x11&hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&selm=7077.26e81ad5%40swift.cs.tcd.ie&rnum=5 for some info about screen dpi
PIXELS_PER_INCH = 96

cursord = {
cursors.MOVE : Gdk.Cursor.new(Gdk.CursorType.FLEUR),
cursors.HAND : Gdk.Cursor.new(Gdk.CursorType.HAND2),
cursors.POINTER : Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR),
cursors.SELECT_REGION : Gdk.Cursor.new(Gdk.CursorType.TCROSS),
cursors.WAIT : Gdk.Cursor.new(Gdk.CursorType.WATCH),
try:
cursord = {
cursors.MOVE : Gdk.Cursor.new(Gdk.CursorType.FLEUR),
cursors.HAND : Gdk.Cursor.new(Gdk.CursorType.HAND2),
cursors.POINTER : Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR),
cursors.SELECT_REGION : Gdk.Cursor.new(Gdk.CursorType.TCROSS),
cursors.WAIT : Gdk.Cursor.new(Gdk.CursorType.WATCH),
}
except TypeError as exc:
# Happens when running headless. Convert to ImportError to cooperate with
# backend switching.
raise ImportError(exc)


class TimerGTK3(TimerBase):
Expand Down
15 changes: 9 additions & 6 deletions src/_macosx.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3025,23 +3025,26 @@ static bool verify_framework(void)
&& GetCurrentProcess(&psn)==noErr
&& SetFrontProcess(&psn)==noErr) return true;
#endif
PyErr_SetString(PyExc_RuntimeError,
PyErr_SetString(PyExc_ImportError,
"Python is not installed as a framework. The Mac OS X backend will "
"not be able to function correctly if Python is not installed as a "
"framework. See the Python documentation for more information on "
"installing Python as a framework on Mac OS X. Please either reinstall "
"Python as a framework, or try one of the other backends. If you are "
"using (Ana)Conda please install python.app and replace the use of 'python' "
"with 'pythonw'. See 'Working with Matplotlib on OSX' "
"in the Matplotlib FAQ for more information.");
"using (Ana)Conda please install python.app and replace the use of "
"'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the "
"Matplotlib FAQ for more information.");
return false;
}

static struct PyMethodDef methods[] = {
{"show",
(PyCFunction)show,
METH_NOARGS,
"Show all the figures and enter the main loop.\nThis function does not return until all Matplotlib windows are closed,\nand is normally not needed in interactive sessions."
"Show all the figures and enter the main loop.\n"
"\n"
"This function does not return until all Matplotlib windows are closed,\n"
"and is normally not needed in interactive sessions."
},
{"choose_save_file",
(PyCFunction)choose_save_file,
Expand All @@ -3053,7 +3056,7 @@ static bool verify_framework(void)
METH_VARARGS,
"Sets the active cursor."
},
{NULL, NULL, 0, NULL}/* sentinel */
{NULL, NULL, 0, NULL} /* sentinel */
};

static struct PyModuleDef moduledef = {
Expand Down

Back | FazBrowse Home | New Git URL