@@ -180,69 +180,71 @@ impl PythonArchBuilder {
180180 }
181181 let mut all_name_allowed = true ;
182182 let mut name_filter: Vec < OYarn > = vec ! [ ] ;
183- if let Some ( all) = import_result. symbol . borrow ( ) . get_content_symbol ( "__all__" , u32:: MAX ) . symbols . first ( ) . cloned ( ) {
184- let all_value = Symbol :: follow_ref ( & EvaluationSymbolPtr :: WEAK ( EvaluationSymbolWeak :: new (
185- Rc :: downgrade ( & all) , None , false
186- ) ) , session, & mut None , false , true , None ) ;
187- if let Some ( all_value_first) = all_value. get ( 0 ) {
188- if !all_value_first. is_expired_if_weak ( ) {
189- let all_upgraded = all_value_first. upgrade_weak ( ) ;
190- if let Some ( all_upgraded_unwrapped) = all_upgraded {
191- let all_upgraded_unwrapped_bw = ( * all_upgraded_unwrapped) . borrow ( ) ;
192- if all_upgraded_unwrapped_bw. evaluations ( ) . is_some ( ) && all_upgraded_unwrapped_bw. evaluations ( ) . unwrap ( ) . len ( ) == 1 {
193- let value = & all_upgraded_unwrapped_bw. evaluations ( ) . unwrap ( ) [ 0 ] . value ;
194- if value. is_some ( ) {
195- let ( nf, parse_error) = self . extract_all_symbol_eval_values ( & value. as_ref ( ) ) ;
196- if parse_error {
197- warn ! ( "error during parsing __all__ import in file {}" , ( * import_result. symbol) . borrow( ) . paths( ) [ 0 ] )
183+ for import_symbol in import_result. symbols {
184+ if let Some ( all) = import_symbol. borrow ( ) . get_content_symbol ( "__all__" , u32:: MAX ) . symbols . first ( ) . cloned ( ) {
185+ let all_value = Symbol :: follow_ref ( & EvaluationSymbolPtr :: WEAK ( EvaluationSymbolWeak :: new (
186+ Rc :: downgrade ( & all) , None , false
187+ ) ) , session, & mut None , false , true , None ) ;
188+ if let Some ( all_value_first) = all_value. get ( 0 ) {
189+ if !all_value_first. is_expired_if_weak ( ) {
190+ let all_upgraded = all_value_first. upgrade_weak ( ) ;
191+ if let Some ( all_upgraded_unwrapped) = all_upgraded {
192+ let all_upgraded_unwrapped_bw = ( * all_upgraded_unwrapped) . borrow ( ) ;
193+ if all_upgraded_unwrapped_bw. evaluations ( ) . is_some ( ) && all_upgraded_unwrapped_bw. evaluations ( ) . unwrap ( ) . len ( ) == 1 {
194+ let value = & all_upgraded_unwrapped_bw. evaluations ( ) . unwrap ( ) [ 0 ] . value ;
195+ if value. is_some ( ) {
196+ let ( nf, parse_error) = self . extract_all_symbol_eval_values ( & value. as_ref ( ) ) ;
197+ if parse_error {
198+ warn ! ( "error during parsing __all__ import in file {}" , import_symbol. borrow( ) . paths( ) [ 0 ] )
199+ }
200+ name_filter = nf;
201+ all_name_allowed = false ;
202+ } else {
203+ warn ! ( "invalid __all__ import in file {} - no value found" , import_symbol. borrow( ) . paths( ) [ 0 ] )
198204 }
199- name_filter = nf;
200- all_name_allowed = false ;
201205 } else {
202- warn ! ( "invalid __all__ import in file {} - no value found" , ( * import_result . symbol ) . borrow( ) . paths( ) [ 0 ] )
206+ warn ! ( "invalid __all__ import in file {} - multiple evaluation found" , import_symbol . borrow( ) . paths( ) [ 0 ] )
203207 }
204208 } else {
205- warn ! ( "invalid __all__ import in file {} - multiple evaluation found" , ( * import_result . symbol ) . borrow( ) . paths( ) [ 0 ] )
209+ warn ! ( "invalid __all__ import in file {} - localizedSymbol not found" , import_symbol . borrow( ) . paths( ) [ 0 ] )
206210 }
207211 } else {
208- warn ! ( "invalid __all__ import in file {} - localizedSymbol not found " , ( * import_result . symbol ) . borrow( ) . paths( ) [ 0 ] )
212+ warn ! ( "invalid __all__ import in file {} - expired symbol " , import_symbol . borrow( ) . paths( ) [ 0 ] )
209213 }
210214 } else {
211- warn ! ( "invalid __all__ import in file {} - expired symbol" , ( * import_result . symbol ) . borrow( ) . paths( ) [ 0 ] )
215+ warn ! ( "invalid __all__ import in file {} - no symbol found " , import_symbol . borrow( ) . paths( ) [ 0 ] )
212216 }
213- } else {
214- warn ! ( "invalid __all__ import in file {} - no symbol found" , ( * import_result. symbol) . borrow( ) . paths( ) [ 0 ] )
215217 }
216- }
217- let mut dep_to_add = vec ! [ ] ;
218- let sym_type = import_result . symbol . borrow ( ) . typ ( ) ;
219- if sym_type != SymType :: COMPILED {
220- if ! Rc :: ptr_eq ( self . sym_stack . last ( ) . unwrap ( ) , & import_result . symbol ) { /*We have to check that the imported symbol is not the current one. It can
221- happen for example in a .pyi that is importing the .pyd file with the same name. As both exists, odools will try to import the pyi a second time in the same file,
222- and so create a borrow error here
223- */
224- let symbol = import_result . symbol . borrow ( ) ;
225- for ( name , loc_syms ) in symbol . iter_symbols ( ) {
226- if all_name_allowed || name_filter . contains ( & name) {
227- let variable = self . sym_stack . last ( ) . unwrap ( ) . borrow_mut ( ) . add_new_variable ( session , OYarn :: from ( name . clone ( ) ) , & import_result . range ) ;
228- let mut loc = variable . borrow_mut ( ) ;
229- loc. as_variable_mut ( ) . is_import_variable = true ;
230- loc . as_variable_mut ( ) . evaluations = Evaluation :: from_sections ( & symbol , loc_syms ) ;
231- dep_to_add . push ( variable . clone ( ) ) ;
218+ let mut dep_to_add = vec ! [ ] ;
219+ let sym_type = import_symbol . borrow ( ) . typ ( ) ;
220+ if sym_type != SymType :: COMPILED {
221+ if ! Rc :: ptr_eq ( self . sym_stack . last ( ) . unwrap ( ) , & import_symbol ) { /*We have to check that the imported symbol is not the current one. It can
222+ happen for example in a .pyi that is importing the .pyd file with the same name. As both exists, odools will try to import the pyi a second time in the same file,
223+ and so create a borrow error here
224+ */
225+ let symbol = import_symbol . borrow ( ) ;
226+ for ( name , loc_syms ) in symbol. iter_symbols ( ) {
227+ if all_name_allowed || name_filter . contains ( & name ) {
228+ let variable = self . sym_stack . last ( ) . unwrap ( ) . borrow_mut ( ) . add_new_variable ( session , OYarn :: from ( name. clone ( ) ) , & import_result . range ) ;
229+ let mut loc = variable . borrow_mut ( ) ;
230+ loc . as_variable_mut ( ) . is_import_variable = true ;
231+ loc. as_variable_mut ( ) . evaluations = Evaluation :: from_sections ( & symbol , loc_syms ) ;
232+ dep_to_add . push ( variable . clone ( ) ) ;
233+ }
232234 }
233235 }
234236 }
235- }
236- for sym in dep_to_add {
237- let mut sym_bw = sym . borrow_mut ( ) ;
238- let evaluation = & sym_bw . as_variable_mut ( ) . evaluations [ 0 ] ;
239- let evaluated_type = & evaluation . symbol ;
240- let evaluated_type = evaluated_type . get_symbol_as_weak ( session , & mut None , & mut self . diagnostics , None ) . weak ;
241- if ! evaluated_type. is_expired ( ) {
242- let evaluated_type = evaluated_type. upgrade ( ) . unwrap ( ) ;
243- let evaluated_type_file = evaluated_type . borrow ( ) . get_file ( ) . unwrap ( ) . clone ( ) . upgrade ( ) . unwrap ( ) ;
244- if ! Rc :: ptr_eq ( & self . file , & evaluated_type_file) {
245- self . file . borrow_mut ( ) . add_dependency ( & mut evaluated_type_file . borrow_mut ( ) , self . current_step , BuildSteps :: ARCH ) ;
237+ for sym in dep_to_add {
238+ let mut sym_bw = sym . borrow_mut ( ) ;
239+ let evaluation = & sym_bw . as_variable_mut ( ) . evaluations [ 0 ] ;
240+ let evaluated_type = & evaluation . symbol ;
241+ let evaluated_type = evaluated_type . get_symbol_as_weak ( session , & mut None , & mut self . diagnostics , None ) . weak ;
242+ if !evaluated_type . is_expired ( ) {
243+ let evaluated_type = evaluated_type . upgrade ( ) . unwrap ( ) ;
244+ let evaluated_type_file = evaluated_type. borrow ( ) . get_file ( ) . unwrap ( ) . clone ( ) . upgrade ( ) . unwrap ( ) ;
245+ if ! Rc :: ptr_eq ( & self . file , & evaluated_type_file ) {
246+ self . file . borrow_mut ( ) . add_dependency ( & mut evaluated_type_file. borrow_mut ( ) , self . current_step , BuildSteps :: ARCH ) ;
247+ }
246248 }
247249 }
248250 }
0 commit comments