◐ Shell
clean mode source ↗

Buffer arguments as PyObject by youknowone · Pull Request #4913 · RustPython/RustPython

Expand Up @@ -2,7 +2,8 @@ use crate::{ builtins::{PyStr, PyStrRef}, common::borrow::{BorrowedValue, BorrowedValueMut}, protocol::PyBuffer, PyObject, PyObjectRef, PyResult, TryFromBorrowedObject, TryFromObject, VirtualMachine, AsObject, PyObject, PyObjectRef, PyResult, TryFromBorrowedObject, TryFromObject, VirtualMachine, };
// Python/getargs.c Expand Down Expand Up @@ -57,6 +58,10 @@ impl ArgBytesLike { pub fn is_empty(&self) -> bool { self.len() == 0 }
pub fn as_object(&self) -> &PyObject { &self.0.obj } }
impl From<ArgBytesLike> for PyBuffer { Expand Down Expand Up @@ -126,6 +131,15 @@ pub enum ArgStrOrBytesLike { Str(PyStrRef), }
impl ArgStrOrBytesLike { pub fn as_object(&self) -> &PyObject { match self { Self::Buf(b) => b.as_object(), Self::Str(s) => s.as_object(), } } }
impl TryFromObject for ArgStrOrBytesLike { fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self> { obj.downcast() Expand Down