aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio/support.py
diff options
context:
space:
mode:
authorGravatar Masood Malekghassemi <atash@google.com>2016-01-28 11:00:24 -0800
committerGravatar Masood Malekghassemi <atash@google.com>2016-01-28 14:56:40 -0800
commit62cc91118884c867c1f022002c4f9e8899078e87 (patch)
tree48acaf39c0d3eabad7f4c493f71c0ee5beeedb8b /src/python/grpcio/support.py
parent9fad88fecf1e0669b5b428beb2d67f25e3147a11 (diff)
Fix Python diagnostics dying on bad diagnosis
Diffstat (limited to 'src/python/grpcio/support.py')
-rw-r--r--src/python/grpcio/support.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/python/grpcio/support.py b/src/python/grpcio/support.py
index bbc509653d..96d9cbf4f3 100644
--- a/src/python/grpcio/support.py
+++ b/src/python/grpcio/support.py
@@ -76,16 +76,23 @@ def _expect_compile(compiler, source_string, error_message):
"Diagnostics found a compilation environment issue:\n{}"
.format(error_message))
-def diagnose_build_ext_error(build_ext, error):
- {
- errors.CompileError: diagnose_compile_error
- }[type(error)](build_ext, error)
-
def diagnose_compile_error(build_ext, error):
"""Attempt to run a few test files through the compiler to see if we can
diagnose the reason for the compile failure."""
for c_check, message in C_CHECKS.items():
_expect_compile(build_ext.compiler, c_check, message)
- raise commands.CommandError(
- "\n\nWe could not diagnose your build failure. Please file an issue at "
- "http://www.github.com/grpc/grpc with `[Python install]` in the title.")
+
+_ERROR_DIAGNOSES = {
+ errors.CompileError: diagnose_compile_error
+}
+
+def diagnose_build_ext_error(build_ext, error, formatted):
+ diagnostic = _ERROR_DIAGNOSES.get(type(error))
+ if diagnostic is None:
+ raise commands.CommandError(
+ "\n\nWe could not diagnose your build failure. Please file an issue at "
+ "http://www.github.com/grpc/grpc with `[Python install]` in the title."
+ "\n\n{}".format(formatted))
+ else:
+ diagnostic(build_ext, error)
+