account for PyObject_IsInstance's new ability to fail
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index b201aaf..3132cf4 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -466,6 +466,7 @@
 	int mode = -1;
 	int dont_inherit = 0;
 	int supplied_flags = 0;
+	int is_ast;
 	PyCompilerFlags cf;
 	PyObject *result = NULL, *cmd, *tmp = NULL;
 	Py_ssize_t length;
@@ -505,7 +506,10 @@
 		return NULL;
 	}
 
-	if (PyAST_Check(cmd)) {
+	is_ast = PyAST_Check(cmd);
+	if (is_ast == -1)
+		return NULL;
+	if (is_ast) {
 		if (supplied_flags & PyCF_ONLY_AST) {
 			Py_INCREF(cmd);
 			result = cmd;