Skip to content

Commit de43a0d

Browse files
committed
Avoid leaking NO_VALUE from sizes
1 parent 4c1bfe9 commit de43a0d

File tree

1 file changed

+10
-4
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type

1 file changed

+10
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,11 +1050,14 @@ Object getItemsizeType(PythonBuiltinClassType cls, @SuppressWarnings("unused") P
10501050
static Object getItemsizeManaged(PythonManagedClass cls, @SuppressWarnings("unused") PNone value,
10511051
@Cached("create()") IsBuiltinClassProfile profile,
10521052
@Cached("create()") ReadAttributeFromObjectNode getName) {
1053+
Object itemsize;
10531054
// recursion anchor; since the metaclass of 'type' is 'type'
10541055
if (profile.profileClass(cls, PythonBuiltinClassType.PythonClass)) {
1055-
return getName.execute(cls, TYPE_ITEMSIZE);
1056+
itemsize = getName.execute(cls, TYPE_ITEMSIZE);
1057+
} else {
1058+
itemsize = getName.execute(cls, __ITEMSIZE__);
10561059
}
1057-
return getName.execute(cls, __ITEMSIZE__);
1060+
return itemsize != PNone.NO_VALUE ? itemsize : 0;
10581061
}
10591062

10601063
@Specialization(guards = "!isNoValue(value)")
@@ -1098,11 +1101,14 @@ Object getBasicsizeType(PythonBuiltinClassType cls, @SuppressWarnings("unused")
10981101
static Object getBasicsizeManaged(PythonManagedClass cls, @SuppressWarnings("unused") PNone value,
10991102
@Cached("create()") IsBuiltinClassProfile profile,
11001103
@Cached("create()") ReadAttributeFromObjectNode getName) {
1104+
Object basicsize;
11011105
// recursion anchor; since the metaclass of 'type' is 'type'
11021106
if (profile.profileClass(cls, PythonBuiltinClassType.PythonClass)) {
1103-
return getName.execute(cls, TYPE_BASICSIZE);
1107+
basicsize = getName.execute(cls, TYPE_BASICSIZE);
1108+
} else {
1109+
basicsize = getName.execute(cls, __BASICSIZE__);
11041110
}
1105-
return getName.execute(cls, __BASICSIZE__);
1111+
return basicsize != PNone.NO_VALUE ? basicsize : 0;
11061112
}
11071113

11081114
@Specialization(guards = "!isNoValue(value)")

0 commit comments

Comments
 (0)