From 9585d2f60a943548f988ddb720ef49dfd8632da2 Mon Sep 17 00:00:00 2001 From: Jeong Yunwon Date: Wed, 27 Apr 2022 02:51:36 +0900 Subject: [PATCH] Constructor for PyByteArray --- vm/src/builtins/bytearray.rs | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/vm/src/builtins/bytearray.rs b/vm/src/builtins/bytearray.rs index de54986b4..21e3ac1b1 100644 --- a/vm/src/builtins/bytearray.rs +++ b/vm/src/builtins/bytearray.rs @@ -95,16 +95,18 @@ pub(crate) fn init(context: &Context) { #[pyimpl( flags(BASETYPE), - with(Initializer, Hashable, Comparable, AsBuffer, AsMapping, AsSequence, Iterable) + with( + Constructor, + Initializer, + Hashable, + Comparable, + AsBuffer, + AsMapping, + AsSequence, + Iterable + ) )] impl PyByteArray { - #[pyslot] - fn slot_new(cls: PyTypeRef, _args: FuncArgs, vm: &VirtualMachine) -> PyResult { - PyByteArray::default() - .into_ref_with_type(vm, cls) - .map(Into::into) - } - #[cfg(debug_assertions)] #[pyproperty] fn exports(&self) -> usize { @@ -706,6 +708,16 @@ impl PyByteArray { }; } +impl Constructor for PyByteArray { + type Args = FuncArgs; + + fn py_new(cls: PyTypeRef, _args: Self::Args, vm: &VirtualMachine) -> PyResult { + PyByteArray::default() + .into_ref_with_type(vm, cls) + .map(Into::into) + } +} + impl Initializer for PyByteArray { type Args = ByteInnerNewOptions;