Skip to content

Commit ff1d4a1

Browse files
authored
Merge pull request RustPython#4710 from youknowone/contructor-baseobjet
Constructor for PyBaseObject
2 parents 7a68485 + f5f0d1a commit ff1d4a1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

vm/src/builtins/object.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::common::hash::PyHash;
33
use crate::{
44
class::PyClassImpl,
55
function::{Either, FuncArgs, PyArithmeticValue, PyComparisonValue, PySetterValue},
6-
types::PyComparisonOp,
6+
types::{Constructor, PyComparisonOp},
77
AsObject, Context, Py, PyObject, PyObjectRef, PyPayload, PyResult, VirtualMachine,
88
};
99

@@ -24,11 +24,10 @@ impl PyPayload for PyBaseObject {
2424
}
2525
}
2626

27-
#[pyclass(flags(BASETYPE))]
28-
impl PyBaseObject {
29-
/// Create and return a new object. See help(type) for accurate signature.
30-
#[pyslot]
31-
fn slot_new(cls: PyTypeRef, _args: FuncArgs, vm: &VirtualMachine) -> PyResult {
27+
impl Constructor for PyBaseObject {
28+
type Args = FuncArgs;
29+
30+
fn py_new(cls: PyTypeRef, _args: Self::Args, vm: &VirtualMachine) -> PyResult {
3231
// more or less __new__ operator
3332
let dict = if cls.is(vm.ctx.types.object_type) {
3433
None
@@ -49,7 +48,10 @@ impl PyBaseObject {
4948

5049
Ok(crate::PyRef::new_ref(PyBaseObject, cls, dict).into())
5150
}
51+
}
5252

53+
#[pyclass(with(Constructor), flags(BASETYPE))]
54+
impl PyBaseObject {
5355
#[pyslot]
5456
fn slot_richcompare(
5557
zelf: &PyObject,

0 commit comments

Comments
 (0)