@@ -212,38 +212,40 @@ def find_nss(locations: list[str], nssname: str) -> ct.CDLL:
212212 fail_errors : list [tuple [str , str ]] = []
213213
214214 OS = ("Windows" , "Darwin" )
215+ sublocations = ("firefox" , "thunderbird" , "" )
215216
216217 for loc in locations :
217- nsslib = os .path .join (loc , nssname )
218- LOG .debug ("Loading NSS library from %s" , nsslib )
219-
220- if SYSTEM in OS :
221- # On windows in order to find DLLs referenced by nss3.dll
222- # we need to have those locations on PATH
223- os .environ ["PATH" ] = ";" .join ([loc , os .environ ["PATH" ]])
224- LOG .debug ("PATH is now %s" , os .environ ["PATH" ])
225- # However this doesn't seem to work on all setups and needs to be
226- # set before starting python so as a workaround we chdir to
227- # Firefox's nss3.dll/libnss3.dylib location
228- if loc :
229- if not os .path .isdir (loc ):
230- # No point in trying to load from paths that don't exist
231- continue
232-
233- workdir = os .getcwd ()
234- os .chdir (loc )
218+ for subloc in sublocations :
219+ nsslib = os .path .join (loc , subloc , nssname )
220+ LOG .debug ("Loading NSS library from %s" , nsslib )
221+
222+ if SYSTEM in OS :
223+ # On windows in order to find DLLs referenced by nss3.dll
224+ # we need to have those locations on PATH
225+ os .environ ["PATH" ] = ";" .join ([loc , os .environ ["PATH" ]])
226+ LOG .debug ("PATH is now %s" , os .environ ["PATH" ])
227+ # However this doesn't seem to work on all setups and needs to be
228+ # set before starting python so as a workaround we chdir to
229+ # Firefox's nss3.dll/libnss3.dylib location
230+ if loc :
231+ if not os .path .isdir (loc ):
232+ # No point in trying to load from paths that don't exist
233+ continue
234+
235+ workdir = os .getcwd ()
236+ os .chdir (loc )
235237
236- try :
237- nss : ct .CDLL = ct .CDLL (nsslib )
238- except OSError as e :
239- fail_errors .append ((nsslib , str (e )))
240- else :
241- LOG .debug ("Loaded NSS library from %s" , nsslib )
242- return nss
243- finally :
244- if SYSTEM in OS and loc :
245- # Restore workdir changed above
246- os .chdir (workdir )
238+ try :
239+ nss : ct .CDLL = ct .CDLL (nsslib )
240+ except OSError as e :
241+ fail_errors .append ((nsslib , str (e )))
242+ else :
243+ LOG .debug ("Loaded NSS library from %s" , nsslib )
244+ return nss
245+ finally :
246+ if SYSTEM in OS and loc :
247+ # Restore workdir changed above
248+ os .chdir (workdir )
247249
248250 else :
249251 LOG .error (
0 commit comments