Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make PyTimeAccess::get_fold() return bool instead of u8 #1397

Merged
merged 1 commit into from Feb 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Add FFI definition `PyCFunction_CheckExact` for Python 3.9 and later. [#1425](https://github.com/PyO3/pyo3/pull/1425)

### Changed
- Change `PyTimeAcces::get_fold()` to return a `bool` instead of a `u8`. [#1397](https://github.com/PyO3/pyo3/pull/1397)
- Deprecate FFI definition `PyCFunction_Call` for Python 3.9 and later. [#1425](https://github.com/PyO3/pyo3/pull/1425)
- Deprecate FFI definitions `PyModule_GetFilename`, `PyMethodDef_INIT`. [#1425](https://github.com/PyO3/pyo3/pull/1425)

Expand Down
14 changes: 7 additions & 7 deletions src/types/datetime.rs
Expand Up @@ -58,7 +58,7 @@ pub trait PyTimeAccess {
fn get_second(&self) -> u8;
fn get_microsecond(&self) -> u32;
#[cfg(not(PyPy))]
fn get_fold(&self) -> u8;
fn get_fold(&self) -> bool;
}

/// Bindings around `datetime.date`
Expand Down Expand Up @@ -256,8 +256,8 @@ impl PyTimeAccess for PyDateTime {
}

#[cfg(not(PyPy))]
fn get_fold(&self) -> u8 {
unsafe { PyDateTime_DATE_GET_FOLD(self.as_ptr()) as u8 }
fn get_fold(&self) -> bool {
unsafe { PyDateTime_DATE_GET_FOLD(self.as_ptr()) > 0 }
}
}

Expand Down Expand Up @@ -338,8 +338,8 @@ impl PyTimeAccess for PyTime {
}

#[cfg(not(PyPy))]
fn get_fold(&self) -> u8 {
unsafe { PyDateTime_TIME_GET_FOLD(self.as_ptr()) as u8 }
fn get_fold(&self) -> bool {
unsafe { PyDateTime_TIME_GET_FOLD(self.as_ptr()) != 0 }
}
}

Expand Down Expand Up @@ -421,8 +421,8 @@ mod tests {
let a = PyDateTime::new_with_fold(py, 2021, 1, 23, 20, 32, 40, 341516, None, false);
let b = PyDateTime::new_with_fold(py, 2021, 1, 23, 20, 32, 40, 341516, None, true);

assert_eq!(a.unwrap().get_fold(), 0);
assert_eq!(b.unwrap().get_fold(), 1);
assert_eq!(a.unwrap().get_fold(), false);
assert_eq!(b.unwrap().get_fold(), true);
});
}
}