Skip to content

Commit 4e4f7df

Browse files
Remove subclass type flags
1 parent 30ac061 commit 4e4f7df

1 file changed

Lines changed: 2 additions & 42 deletions

File tree

crates/capi/src/object.rs

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,7 @@ use crate::PyObject;
22
use crate::pystate::with_vm;
33
use core::ffi::{c_int, c_uint, c_ulong};
44
use rustpython_vm::builtins::PyType;
5-
use rustpython_vm::{AsObject, Context, Py};
6-
7-
const PY_TPFLAGS_LONG_SUBCLASS: u32 = 1 << 24;
8-
const PY_TPFLAGS_LIST_SUBCLASS: u32 = 1 << 25;
9-
const PY_TPFLAGS_TUPLE_SUBCLASS: u32 = 1 << 26;
10-
const PY_TPFLAGS_BYTES_SUBCLASS: u32 = 1 << 27;
11-
const PY_TPFLAGS_UNICODE_SUBCLASS: u32 = 1 << 28;
12-
const PY_TPFLAGS_DICT_SUBCLASS: u32 = 1 << 29;
13-
const PY_TPFLAGS_BASE_EXC_SUBCLASS: u32 = 1 << 30;
14-
const PY_TPFLAGS_TYPE_SUBCLASS: u32 = 1 << 31;
5+
use rustpython_vm::{AsObject, Py};
156

167
pub type PyTypeObject = Py<PyType>;
178

@@ -31,39 +22,8 @@ pub unsafe extern "C" fn Py_IS_TYPE(op: *mut PyObject, ty: *mut PyTypeObject) ->
3122

3223
#[unsafe(no_mangle)]
3324
pub unsafe extern "C" fn PyType_GetFlags(ptr: *const PyTypeObject) -> c_ulong {
34-
let ctx = Context::genesis();
35-
let zoo = &ctx.types;
36-
let exp_zoo = &ctx.exceptions;
37-
3825
let ty = unsafe { &*ptr };
39-
let mut flags = ty.slots.flags.bits() as u32;
40-
41-
if ty.is_subtype(zoo.int_type) {
42-
flags |= PY_TPFLAGS_LONG_SUBCLASS;
43-
}
44-
if ty.is_subtype(zoo.list_type) {
45-
flags |= PY_TPFLAGS_LIST_SUBCLASS
46-
}
47-
if ty.is_subtype(zoo.tuple_type) {
48-
flags |= PY_TPFLAGS_TUPLE_SUBCLASS;
49-
}
50-
if ty.is_subtype(zoo.bytes_type) {
51-
flags |= PY_TPFLAGS_BYTES_SUBCLASS;
52-
}
53-
if ty.is_subtype(zoo.str_type) {
54-
flags |= PY_TPFLAGS_UNICODE_SUBCLASS;
55-
}
56-
if ty.is_subtype(zoo.dict_type) {
57-
flags |= PY_TPFLAGS_DICT_SUBCLASS;
58-
}
59-
if ty.is_subtype(exp_zoo.base_exception_type) {
60-
flags |= PY_TPFLAGS_BASE_EXC_SUBCLASS;
61-
}
62-
if ty.is_subtype(zoo.type_type) {
63-
flags |= PY_TPFLAGS_TYPE_SUBCLASS;
64-
}
65-
66-
flags as c_ulong
26+
ty.slots.flags.bits() as u32 as c_ulong
6727
}
6828

6929
#[unsafe(no_mangle)]

0 commit comments

Comments
 (0)