From 8158bcf6da8163fd35f26b59a08fc7f5a9abce11 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sun, 30 Nov 2025 15:28:05 +0100 Subject: fix(treewide): Avoid using deprecated functions or patterns --- crates/yt_dlp/src/lib.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'crates/yt_dlp/src/lib.rs') diff --git a/crates/yt_dlp/src/lib.rs b/crates/yt_dlp/src/lib.rs index 6be5e87..4b252de 100644 --- a/crates/yt_dlp/src/lib.rs +++ b/crates/yt_dlp/src/lib.rs @@ -115,7 +115,7 @@ impl YoutubeDL { /// # Errors /// If python attribute access fails. pub fn version(&self) -> Result<(String, String), PythonError> { - Python::with_gil(|py| { + Python::attach(|py| { let yt_dlp = py .import(intern!(py, "yt_dlp")) .wrap_exc(py)? @@ -189,7 +189,7 @@ impl YoutubeDL { download: bool, process: bool, ) -> Result { - Python::with_gil(|py| { + Python::attach(|py| { let inner = self .inner .bind(py) @@ -202,14 +202,14 @@ impl YoutubeDL { py_kw_args!(py => download = download, process = process), ) .wrap_exc(py)? - .downcast_into::() + .cast_into::() .expect("This is a dict"); // Resolve the generator object if let Ok(generator) = result.get_item(intern!(py, "entries")) { if generator.is_instance_of::() { // already resolved. Do nothing - } else if let Ok(generator) = generator.downcast::() { + } else if let Ok(generator) = generator.cast::() { // A python generator object. let max_backlog = json_try_get!(self.options, "playlistend", as_u64) .map_or(10000, |playlistend| { @@ -269,7 +269,7 @@ impl YoutubeDL { ie_result: InfoJson, download: bool, ) -> Result { - Python::with_gil(|py| { + Python::attach(|py| { let inner = self .inner .bind(py) @@ -282,7 +282,7 @@ impl YoutubeDL { py_kw_args!(py => download = download), ) .wrap_exc(py)? - .downcast_into::() + .cast_into::() .expect("This is a dict"); let result = self.prepare_info_json(&result, py)?; @@ -296,7 +296,7 @@ impl YoutubeDL { /// # Errors /// If python operations fail. pub fn close(&self) -> Result<(), close::Error> { - Python::with_gil(|py| { + Python::attach(|py| { debug!("Closing YoutubeDL."); let inner = self @@ -324,7 +324,7 @@ impl YoutubeDL { let value = sanitize.call((info,), None).wrap_exc(py)?; - let result = value.downcast::().expect("This should stay a dict"); + let result = value.cast::().expect("This should stay a dict"); Ok(json_dumps(result)) } -- cgit 1.4.1