diff --git a/configure.ac b/configure.ac
index 990a59db2a..57a187aa11 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1765,7 +1765,7 @@ then
 
 		AC_MSG_CHECKING([for python distutils])
 		python_result="`$PYTHON -c 'import distutils;' 2>&1`"
-		if test -z "$python_result" ; then
+		if test $? -eq 0; then
 			python_has_distutils="yes"
 		else
 			python_has_distutils="no"
@@ -1886,7 +1886,7 @@ then
 
 		AC_MSG_CHECKING([for python3 distutils])
 		python3_result="`$PYTHON3 -c 'import distutils;' 2>&1`"
-		if test -z "$python3_result" ; then
+		if test $? -eq 0 ; then
 			python3_has_distutils="yes"
 		else
 			python3_has_distutils="no"
