Skip to content

Commit

Permalink
tuple: add back old slice() for deprecation cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
birkenfeld committed Aug 24, 2021
1 parent c522a9c commit 0972167
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- `PySequence`'s `in_place_repeat` and `in_place_concat` now return the result instead of `()`, which is needed
in case of immutable sequences. [#1803](https://github.com/PyO3/pyo3/pull/1803)
- Deprecate `PyTuple::split_from`. [#1804](https://github.com/PyO3/pyo3/pull/1804)
- `PyTuple`'s `slice` method is now called `get_slice` for consistency. [#](https://github.com/PyO3/pyo3/pull/)
- Deprecate `PyTuple::slice`, new method `get_slice` added with proper index types. [#1828](https://github.com/PyO3/pyo3/pull/1828)

## [0.14.3] - 2021-08-22

Expand Down
17 changes: 16 additions & 1 deletion src/types/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,22 @@ impl PyTuple {
}
}

#[deprecated(since = "0.15.0", note = "use tuple.get_slice(low, tuple.len()) instead")]
#[deprecated(since = "0.15.0", note = "use self.get_slice instead")]
/// Takes the slice `self[low:high]` and returns it as a new tuple.
///
/// Indices must be nonnegative, and out-of-range indices are clipped to
/// `self.len()`.
pub fn slice(&self, low: isize, high: isize) -> &PyTuple {
unsafe {
self.py()
.from_owned_ptr(ffi::PyTuple_GetSlice(self.as_ptr(), low, high))
}
}

#[deprecated(
since = "0.15.0",
note = "use tuple.get_slice(low, tuple.len()) instead"
)]
/// Takes a slice of the tuple from `low` to the end and returns it as a new tuple.
pub fn split_from(&self, low: usize) -> &PyTuple {
unsafe {
Expand Down

0 comments on commit 0972167

Please sign in to comment.