Change Python::run to return PyResult<()>

This commit is contained in:
kngwyu 2019-05-08 15:46:31 +09:00
parent c4c75bbf81
commit 803f18e61d
2 changed files with 6 additions and 3 deletions

View File

@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* Add `marshal` module. [#460](https://github.com/PyO3/pyo3/pull/460)
### Changed
* `Python::run` returns `PyResult<()>` instead of `PyResult<&PyAny>`.
* Methods decorated with `#[getter]` and `#[setter]` can now omit wrapping the
result type in `PyResult` if they don't raise exceptions.

View File

@ -108,8 +108,11 @@ impl<'p> Python<'p> {
code: &str,
globals: Option<&PyDict>,
locals: Option<&PyDict>,
) -> PyResult<&'p PyAny> {
self.run_code(code, ffi::Py_file_input, globals, locals)
) -> PyResult<()> {
let res = self.run_code(code, ffi::Py_file_input, globals, locals);
res.map(|obj| {
debug_assert!(crate::ObjectProtocol::is_none(obj));
})
}
/// Runs code in the given context.