`PyErr::api_call_failed` should return a `SystemError` when no error is set
17f94e2888/Python/ceval.c (L4330-L4333)
This commit is contained in:
parent
93b25edba1
commit
3ba24bee14
|
@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Change `PyErr::fetch()` to return `Option<PyErr>`. [#1728](https://github.com/PyO3/pyo3/pull/1728)
|
- Change `PyErr::fetch()` to return `Option<PyErr>`. [#1717](https://github.com/PyO3/pyo3/pull/1717)
|
||||||
|
|
||||||
## [0.14.2] - 2021-08-09
|
## [0.14.2] - 2021-08-09
|
||||||
|
|
||||||
|
|
|
@ -254,9 +254,20 @@ impl PyErr {
|
||||||
/// Retrieves the current error from the Python interpreter's global state.
|
/// Retrieves the current error from the Python interpreter's global state.
|
||||||
///
|
///
|
||||||
/// The error is cleared from the Python interpreter.
|
/// The error is cleared from the Python interpreter.
|
||||||
/// Panics if no error is set
|
/// If no error is set, returns a `SystemError` in release mode,
|
||||||
|
/// panics in debug mode.
|
||||||
pub(crate) fn api_call_failed(py: Python) -> PyErr {
|
pub(crate) fn api_call_failed(py: Python) -> PyErr {
|
||||||
PyErr::fetch(py).expect("exception missing")
|
#[cfg(debug_assertions)]
|
||||||
|
{
|
||||||
|
PyErr::fetch(py).expect("error return without exception set")
|
||||||
|
}
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
{
|
||||||
|
use crate::exceptions::PySystemError;
|
||||||
|
|
||||||
|
PyErr::fetch(py)
|
||||||
|
.unwrap_or_else(|| PySystemError::new_err("error return without exception set"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new exception type with the given name, which must be of the form
|
/// Creates a new exception type with the given name, which must be of the form
|
||||||
|
|
Loading…
Reference in New Issue