Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 32b1d0b

Browse files
committed
Re-worked exception handling to avoid masking shared library dependency
exceptions. svn path=/trunk/matplotlib/; revision=600
1 parent d71a32f commit 32b1d0b

3 files changed

Lines changed: 19 additions & 16 deletions

File tree

lib/matplotlib/_image.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@
44
try:
55
from matplotlib._na_image import *
66
except ImportError:
7-
print "numarray wasn't available at compile time so the numarray"
8-
print "extensions were not built. Please make sure you have a working"
9-
print "numarray installation and then rebuild matplotlib."
10-
sys.exit(1)
7+
numerix._import_fail_message("_image", "_na")
8+
raise
119
else:
1210
try:
1311
from matplotlib._nc_image import *
1412
except ImportError:
15-
print "Numeric wasn't available at compile time so the Numeric"
16-
print "extensions were not built. Please make sure you have a working"
17-
print "Numeric installation and then rebuild matplotlib."
18-
sys.exit(1)
13+
numerix._import_fail_message("_image", "_nc")
14+
raise

lib/matplotlib/_transforms.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@
44
try:
55
from matplotlib._na_transforms import *
66
except ImportError:
7-
print "numarray wasn't available at compile time so the numarray"
8-
print "extensions were not built. Please make sure you have a working"
9-
print "numarray installation and then rebuild matplotlib."
10-
sys.exit(1)
7+
numerix._import_fail_message("_transforms", "_na")
8+
raise
119
else:
1210
try:
1311
from matplotlib._nc_transforms import *
1412
except ImportError:
15-
print "Numeric wasn't available at compile time so the Numeric"
16-
print "extensions were not built. Please make sure you have a working"
17-
print "Numeric installation and then rebuild matplotlib."
18-
sys.exit(1)
13+
numerix._import_fail_message("_transforms", "_nc")
14+
raise

lib/matplotlib/numerix.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,14 @@
5858
verbose.report('numerix %s'%version)
5959
# a bug fix for blas numeric suggested by Fernando Perez
6060
matrixmultiply=dot
61+
62+
63+
def _import_fail_message(module, version):
64+
"""Prints a message when the array package specific version of an extension
65+
fails to import correctly.
66+
"""
67+
_dict = { "which" : which[0],
68+
"module" : module,
69+
"specific" : version + module
70+
}
71+
print """\nThe import of the %(which)s version of the %(module)s module, %(specific)s, failed.\nThis is either because %(which)s was unavailable when matplotlib was compiled,\nor because a dependency of %(specific)s could not be satisfied.\nIf it appears that %(specific)s was not built, make sure you have a working copy of\n%(which)s and then re-install matplotlib. Otherwise, the following traceback gives more details:\n""" % _dict

0 commit comments

Comments
 (0)