Skip to content

Commit a5d32a3

Browse files
Merge branch 'v1.4-andium' into adbc_driver
2 parents fa397d9 + dc5e746 commit a5d32a3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/duckdb_py/common/exceptions.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,12 @@ void PyThrowException(ErrorData &error, PyObject *http_exception) {
310310
}
311311
}
312312

313+
static void UnsetPythonException() {
314+
if (PyErr_Occurred()) {
315+
PyErr_Clear();
316+
}
317+
}
318+
313319
/**
314320
* @see https://peps.python.org/pep-0249/#exceptions
315321
*/
@@ -381,6 +387,7 @@ void RegisterExceptions(const py::module &m) {
381387
}
382388
} catch (const duckdb::Exception &ex) {
383389
duckdb::ErrorData error(ex);
390+
UnsetPythonException();
384391
PyThrowException(error, HTTP_EXCEPTION.ptr());
385392
} catch (const py::builtin_exception &ex) {
386393
// These represent Python exceptions, we don't want to catch these
@@ -391,6 +398,7 @@ void RegisterExceptions(const py::module &m) {
391398
// we need to pass non-DuckDB exceptions through as-is
392399
throw;
393400
}
401+
UnsetPythonException();
394402
PyThrowException(error, HTTP_EXCEPTION.ptr());
395403
}
396404
});

0 commit comments

Comments
 (0)