Skip to content

Commit

Permalink
update uses of deprecated timezone_utc
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Feb 12, 2024
1 parent 10cb090 commit 43217dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/conversions/chrono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ use crate::types::any::PyAnyMethods;
use crate::types::datetime::timezone_from_offset;
#[cfg(not(Py_LIMITED_API))]
use crate::types::{
timezone_utc, PyDate, PyDateAccess, PyDateTime, PyDelta, PyDeltaAccess, PyTime, PyTimeAccess,
PyTzInfo, PyTzInfoAccess,
timezone_utc_bound, PyDate, PyDateAccess, PyDateTime, PyDelta, PyDeltaAccess, PyTime,
PyTimeAccess, PyTzInfo, PyTzInfoAccess,
};
#[cfg(Py_LIMITED_API)]
use crate::{intern, DowncastError};
Expand Down Expand Up @@ -365,7 +365,7 @@ impl FromPyObject<'_> for FixedOffset {

impl ToPyObject for Utc {
fn to_object(&self, py: Python<'_>) -> PyObject {
timezone_utc(py).into()
timezone_utc_bound(py).into()
}
}

Expand All @@ -377,7 +377,7 @@ impl IntoPy<PyObject> for Utc {

impl FromPyObject<'_> for Utc {
fn extract_bound(ob: &Bound<'_, PyAny>) -> PyResult<Utc> {
let py_utc = timezone_utc(ob.py());
let py_utc = timezone_utc_bound(ob.py());
if ob.eq(py_utc)? {
Ok(Utc)
} else {
Expand Down Expand Up @@ -557,8 +557,8 @@ impl DatetimeTypes {
}

#[cfg(Py_LIMITED_API)]
fn timezone_utc(py: Python<'_>) -> &PyAny {
DatetimeTypes::get(py).timezone_utc.as_ref(py)
fn timezone_utc_bound(py: Python<'_>) -> Bound<'_, PyAny> {
DatetimeTypes::get(py).timezone_utc.bind(py).clone()
}

#[cfg(test)]
Expand Down Expand Up @@ -912,7 +912,7 @@ mod tests {
let minute = 8;
let second = 9;
let micro = 999_999;
let tz_utc = timezone_utc(py);
let tz_utc = timezone_utc_bound(py);
let py_datetime = new_py_datetime_ob(
py,
"datetime",
Expand Down
7 changes: 5 additions & 2 deletions src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ pub use self::capsule::PyCapsule;
#[cfg(not(Py_LIMITED_API))]
pub use self::code::PyCode;
pub use self::complex::PyComplex;
#[allow(deprecated)]
#[cfg(not(Py_LIMITED_API))]
pub use self::datetime::timezone_utc;
#[cfg(not(Py_LIMITED_API))]
pub use self::datetime::{
timezone_utc, timezone_utc_bound, PyDate, PyDateAccess, PyDateTime, PyDelta, PyDeltaAccess,
PyTime, PyTimeAccess, PyTzInfo, PyTzInfoAccess,
timezone_utc_bound, PyDate, PyDateAccess, PyDateTime, PyDelta, PyDeltaAccess, PyTime,
PyTimeAccess, PyTzInfo, PyTzInfoAccess,
};
pub use self::dict::{IntoPyDict, PyDict};
#[cfg(not(PyPy))]
Expand Down

0 comments on commit 43217dd

Please sign in to comment.