@@ -2341,19 +2341,28 @@ private PythonClass typeMetaclass(VirtualFrame frame, String name, PTuple bases,
2341
2341
// have slots
2342
2342
2343
2343
// Make it into a list
2344
- SequenceStorage slotList ;
2344
+ SequenceStorage slotsStorage ;
2345
+ Object slotsObject ;
2345
2346
if (slots instanceof String ) {
2346
- slotList = factory ().createList (new Object []{slots }).getSequenceStorage ();
2347
+ slotsObject = factory ().createList (new Object []{slots });
2348
+ slotsStorage = ((PList ) slotsObject ).getSequenceStorage ();
2349
+ } else if (slots instanceof PTuple ) {
2350
+ slotsObject = slots ;
2351
+ slotsStorage = ((PTuple ) slots ).getSequenceStorage ();
2352
+ } else if (slots instanceof PList ) {
2353
+ slotsObject = slots ;
2354
+ slotsStorage = ((PList ) slots ).getSequenceStorage ();
2347
2355
} else {
2348
- slotList = getCastToListNode ().execute (frame , slots ).getSequenceStorage ();
2356
+ slotsObject = getCastToListNode ().execute (frame , slots );
2357
+ slotsStorage = ((PList ) slotsObject ).getSequenceStorage ();
2349
2358
}
2350
- int slotlen = getListLenNode ().execute (slotList );
2359
+ int slotlen = getListLenNode ().execute (slotsStorage );
2351
2360
// TODO: tfel - check if slots are allowed. They are not if the base class is var
2352
2361
// sized
2353
2362
2354
2363
for (int i = 0 ; i < slotlen ; i ++) {
2355
2364
String slotName ;
2356
- Object element = getSlotItemNode ().execute (frame , slotList , i );
2365
+ Object element = getSlotItemNode ().execute (frame , slotsStorage , i );
2357
2366
// Check valid slot name
2358
2367
if (element instanceof String ) {
2359
2368
slotName = (String ) element ;
@@ -2378,13 +2387,15 @@ private PythonClass typeMetaclass(VirtualFrame frame, String name, PTuple bases,
2378
2387
PythonContext context = getContextRef ().get ();
2379
2388
Object state = ForeignCallContext .enter (frame , context , this );
2380
2389
try {
2381
- PTuple newSlots = copySlots (name , slotList , slotlen , addDict , false , namespace , nslib );
2382
- pythonClass .setAttribute (__SLOTS__ , newSlots );
2390
+ pythonClass .setAttribute (__SLOTS__ , slotsObject );
2383
2391
if (basesArray .length > 1 ) {
2384
2392
// TODO: tfel - check if secondary bases provide weakref or dict when we
2385
2393
// don't already have one
2386
2394
}
2387
2395
2396
+ // checks for some name errors too
2397
+ PTuple newSlots = copySlots (name , slotsStorage , slotlen , addDict , false , namespace , nslib );
2398
+
2388
2399
// add native slot descriptors
2389
2400
if (pythonClass .needsNativeAllocation ()) {
2390
2401
addNativeSlots (pythonClass , newSlots );
0 commit comments