@@ -2,16 +2,7 @@ use crate::PyObject;
22use crate :: pystate:: with_vm;
33use core:: ffi:: { c_int, c_uint, c_ulong} ;
44use 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
167pub 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) ]
3324pub 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