better constrain for PyNativeException::new

This commit is contained in:
Nikolay Kim 2017-07-26 14:56:08 -07:00
parent efba0742e8
commit fc3ab84bfa
2 changed files with 5 additions and 5 deletions

View File

@ -144,9 +144,9 @@ The code snippet above will raise `OSError` in Python if `TcpListener::bind()` r
types so `try!` macro or `?` operator can be used.
```rust
use pyo3::{PyResult, ToPyErr};
use pyo3::*;
fn parse_int(py: Python, s: String) -> PyResult<usize> {
fn parse_int(s: String) -> PyResult<usize> {
Ok(s.parse::<usize>()?)
}
```
@ -161,7 +161,7 @@ It is possible to use exception defined in python code as native rust types.
for that exception.
```rust
use pyo3::{PyErr, PyResult, ToPyErr, exc};
use pyo3::{PyErr, PyResult, exc};
import_exception!(asyncio, CancelledError)

View File

@ -81,8 +81,8 @@ pub trait PyNativeException {
/// Name of exception
const NAME: &'static str;
fn new<S: PyTypeObject, T: ToPyObject + 'static>(args: T) -> PyErr {
PyErr::new::<S, T>(args)
fn new<T: ToPyObject + 'static>(args: T) -> PyErr where Self: PyTypeObject + Sized {
PyErr::new::<Self, T>(args)
}
fn type_object_ptr() -> *mut ffi::PyTypeObject {