@@ -11,7 +11,7 @@ use crate::obj::objtype::PyClassRef;
11
11
use crate :: obj:: { objbool, objiter} ;
12
12
use crate :: pyobject:: {
13
13
BorrowValue , Either , IdProtocol , IntoPyObject , PyArithmaticValue , PyClassImpl ,
14
- PyComparisonValue , PyIterable , PyObject , PyObjectRef , PyRef , PyResult , PyValue , TryFromObject ,
14
+ PyComparisonValue , PyIterable , PyObjectRef , PyRef , PyResult , PyValue , TryFromObject ,
15
15
TypeProtocol ,
16
16
} ;
17
17
use crate :: VirtualMachine ;
@@ -203,13 +203,10 @@ macro_rules! def_array_enum {
203
203
$( ArrayContentType :: $n( v) => {
204
204
let elements = v. get_slice_items( vm, & slice) ?;
205
205
let sliced = ArrayContentType :: $n( elements) ;
206
- let obj = PyObject :: new(
207
- PyArray {
208
- array: PyRwLock :: new( sliced)
209
- } ,
210
- PyArray :: class( vm) ,
211
- None
212
- ) ;
206
+ let obj = PyArray {
207
+ array: PyRwLock :: new( sliced)
208
+ }
209
+ . into_simple_object( vm) ;
213
210
Ok ( obj)
214
211
} ) *
215
212
}
@@ -340,13 +337,10 @@ macro_rules! def_array_enum {
340
337
$( ArrayContentType :: $n( v) => if let ArrayContentType :: $n( other) = other {
341
338
let elements = v. iter( ) . chain( other. iter( ) ) . cloned( ) . collect( ) ;
342
339
let sliced = ArrayContentType :: $n( elements) ;
343
- let obj = PyObject :: new(
344
- PyArray {
345
- array: PyRwLock :: new( sliced)
346
- } ,
347
- PyArray :: class( vm) ,
348
- None
349
- ) ;
340
+ let obj = PyArray {
341
+ array: PyRwLock :: new( sliced)
342
+ }
343
+ . into_simple_object( vm) ;
350
344
Ok ( obj)
351
345
} else {
352
346
Err ( vm. new_type_error( "bad argument type for built-in operation" . to_owned( ) ) )
@@ -371,13 +365,10 @@ macro_rules! def_array_enum {
371
365
$( ArrayContentType :: $n( v) => {
372
366
let elements = v. iter( ) . cycle( ) . take( v. len( ) * counter) . cloned( ) . collect( ) ;
373
367
let sliced = ArrayContentType :: $n( elements) ;
374
- PyObject :: new(
375
- PyArray {
376
- array: PyRwLock :: new( sliced)
377
- } ,
378
- PyArray :: class( vm) ,
379
- None
380
- )
368
+ PyArray {
369
+ array: PyRwLock :: new( sliced)
370
+ }
371
+ . into_simple_object( vm)
381
372
} ) *
382
373
}
383
374
}
0 commit comments