Complete the PR
This commit is contained in:
parent
39d3ceb551
commit
4bf448ecaa
|
@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||
* `PySet::new` and `PyFrozenSet::new` now return `PyResult<&Py[Frozen]Set>`; exceptions are raised if
|
||||
the items are not hashable.
|
||||
* Fixed building using `venv` on Windows.
|
||||
* `PyTuple::new` now returns `&PyTuple` instead of `Py<PyTuple>`.
|
||||
|
||||
## [0.6.0] - 2018-03-28
|
||||
|
||||
|
|
|
@ -21,7 +21,10 @@ pyobject_native_type!(PyTuple, ffi::PyTuple_Type, ffi::PyTuple_Check);
|
|||
|
||||
impl PyTuple {
|
||||
/// Construct a new tuple with the given elements.
|
||||
pub fn new<'p, T, U>(py: Python<'p>, elements: impl IntoIterator<Item = T, IntoIter = U>) -> &'p PyTuple
|
||||
pub fn new<'p, T, U>(
|
||||
py: Python<'p>,
|
||||
elements: impl IntoIterator<Item = T, IntoIter = U>,
|
||||
) -> &'p PyTuple
|
||||
where
|
||||
T: ToPyObject,
|
||||
U: ExactSizeIterator<Item = T>,
|
||||
|
|
|
@ -94,8 +94,7 @@ impl Drop for ClassWithDrop {
|
|||
let py = Python::assume_gil_acquired();
|
||||
|
||||
let _empty1: Py<PyTuple> = FromPy::from_py(PyTuple::empty(py), py);
|
||||
let _empty2: Py<PyTuple> = FromPy::from_py(PyTuple::empty(py), py);
|
||||
let _empty2: PyObject = _empty2.into();
|
||||
let _empty2 = PyTuple::empty(py).into_object(py);
|
||||
let _empty3: &PyAny = py.from_owned_ptr(ffi::PyTuple_New(0));
|
||||
}
|
||||
}
|
||||
|
@ -111,9 +110,10 @@ fn create_pointers_in_drop() {
|
|||
{
|
||||
let gil = Python::acquire_gil();
|
||||
let py = gil.python();
|
||||
let empty: Py<PyTuple> = FromPy::from_py(PyTuple::empty(py), py);
|
||||
let empty = PyTuple::empty(py).into_object(py);
|
||||
ptr = empty.as_ptr();
|
||||
cnt = empty.get_refcnt() - 1;
|
||||
// substract 2, because `PyTuple::empty(py).into_object(py)` increases the refcnt by 2
|
||||
cnt = empty.get_refcnt() - 2;
|
||||
let inst = Py::new(py, ClassWithDrop {}).unwrap();
|
||||
drop(inst);
|
||||
}
|
||||
|
|
|
@ -129,9 +129,10 @@ impl PickleSupport {
|
|||
obj.init({ PickleSupport {} });
|
||||
}
|
||||
|
||||
pub fn __reduce__(slf: PyRef<Self>) -> PyResult<(PyObject, Py<PyTuple>, PyObject)> {
|
||||
let gil = Python::acquire_gil();
|
||||
let py = gil.python();
|
||||
pub fn __reduce__<'py>(
|
||||
slf: PyRef<Self>,
|
||||
py: Python<'py>,
|
||||
) -> PyResult<(PyObject, &'py PyTuple, PyObject)> {
|
||||
let cls = slf.to_object(py).getattr(py, "__class__")?;
|
||||
let dict = slf.to_object(py).getattr(py, "__dict__")?;
|
||||
Ok((cls, PyTuple::empty(py), dict))
|
||||
|
|
Loading…
Reference in New Issue