File tree 1 file changed +22
-18
lines changed
1 file changed +22
-18
lines changed Original file line number Diff line number Diff line change @@ -204,24 +204,28 @@ fn subs_tvars(
204
204
argitems : & [ PyObjectRef ] ,
205
205
vm : & VirtualMachine ,
206
206
) -> PyResult {
207
- let sub_params = obj. clone ( ) . get_attr ( "__parameters__" , vm) ?;
208
- if let Ok ( sub_params) = PyTupleRef :: try_from_object ( vm, sub_params) {
209
- let sub_args = sub_params
210
- . as_slice ( )
211
- . iter ( )
212
- . map ( |arg| {
213
- if let Some ( idx) = tuple_index ( params, arg) {
214
- argitems[ idx] . clone ( )
215
- } else {
216
- arg. clone ( )
217
- }
218
- } )
219
- . collect :: < Vec < _ > > ( ) ;
220
- let sub_args: PyObjectRef = PyTuple :: new_ref ( sub_args, & vm. ctx ) . into ( ) ;
221
- obj. get_item ( sub_args, vm)
222
- } else {
223
- Ok ( obj)
224
- }
207
+ obj. clone_class ( )
208
+ . get_attr ( "__parameters__" )
209
+ . and_then ( |sub_params| {
210
+ PyTupleRef :: try_from_object ( vm, sub_params)
211
+ . ok ( )
212
+ . map ( |sub_params| {
213
+ let sub_args = sub_params
214
+ . as_slice ( )
215
+ . iter ( )
216
+ . map ( |arg| {
217
+ if let Some ( idx) = tuple_index ( params, arg) {
218
+ argitems[ idx] . clone ( )
219
+ } else {
220
+ arg. clone ( )
221
+ }
222
+ } )
223
+ . collect :: < Vec < _ > > ( ) ;
224
+ let sub_args: PyObjectRef = PyTuple :: new_ref ( sub_args, & vm. ctx ) . into ( ) ;
225
+ obj. get_item ( sub_args, vm)
226
+ } )
227
+ } )
228
+ . unwrap_or ( Ok ( obj) )
225
229
}
226
230
227
231
impl AsMapping for PyGenericAlias {
You can’t perform that action at this time.
0 commit comments