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) * Add `marshal` module. [#460](https://github.com/PyO3/pyo3/pull/460)
### Changed ### Changed
* `Python::run` returns `PyResult<()>` instead of `PyResult<&PyAny>`.
* Methods decorated with `#[getter]` and `#[setter]` can now omit wrapping the * Methods decorated with `#[getter]` and `#[setter]` can now omit wrapping the
result type in `PyResult` if they don't raise exceptions. result type in `PyResult` if they don't raise exceptions.

View file

@ -108,8 +108,11 @@ impl<'p> Python<'p> {
code: &str, code: &str,
globals: Option<&PyDict>, globals: Option<&PyDict>,
locals: Option<&PyDict>, locals: Option<&PyDict>,
) -> PyResult<&'p PyAny> { ) -> PyResult<()> {
self.run_code(code, ffi::Py_file_input, globals, locals) 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. /// Runs code in the given context.